Skip to content

Commit

Permalink
Merge pull request EOSIO#41 from EOSIO/name_literal
Browse files Browse the repository at this point in the history
_n literal operator
  • Loading branch information
larryk85 authored Aug 9, 2018
2 parents 32baafc + a94ca1c commit a4615b6
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 a4615b6

Please sign in to comment.