From a94ca1c44183b7a5dad95a82b30b44f9a665150f Mon Sep 17 00:00:00 2001 From: Todd Fleming Date: Thu, 9 Aug 2018 11:47:23 -0400 Subject: [PATCH] _n literal operator --- libraries/eosiolib/types.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/eosiolib/types.hpp b/libraries/eosiolib/types.hpp index e2776a3292f..556bfd5c3a5 100644 --- a/libraries/eosiolib/types.hpp +++ b/libraries/eosiolib/types.hpp @@ -119,7 +119,7 @@ namespace eosio { * @brief Conversion Operator * @return uint64_t - Converted result */ - operator uint64_t()const { return value; } + constexpr operator uint64_t()const { return value; } // keep in sync with name::operator string() in eosio source code definition for name std::string to_string() const { @@ -218,3 +218,12 @@ inline bool operator==(const checksum160& lhs, const checksum160& rhs) { inline bool operator!=(const checksum160& lhs, const checksum160& rhs) { return memcmp(&lhs, &rhs, sizeof(lhs)) != 0; } + +/** + * name literal operator + * + * @brief "foo"_n is a shortcut for name{eosio::string_to_name("foo")} + */ +inline constexpr eosio::name operator""_n(const char* s, std::size_t) { + return {eosio::string_to_name(s)}; +}