Skip to content

Commit

Permalink
_n literal operator
Browse files Browse the repository at this point in the history
  • Loading branch information
tbfleming committed Aug 9, 2018
1 parent 32baafc commit a94ca1c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libraries/eosiolib/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)};
}

0 comments on commit a94ca1c

Please sign in to comment.