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)}; +}