I know this might be a dummy question, but it is troubling me a lot.
I am trying to follow the tutorial at https://github.com/EOSIO/eos/wiki/Tutorials#2-currency-contract-walkthrough, and in a lot of the places it has this syntax "N()", like:
typedef eosio::token<uint64_t,N(currency)> currency_tokens;
or in contracts/currency/currency.cpp:73
const uint64_t key = N(account);
I am coming from Java and Python, and knows a little about C++ and template, and it is kind of hard for me to understand what N(something) does here. Does it act as a generic constructor (like new Object() in Java), or it is something else?
I think it is a #define. So expanded at pre-processor stage.
@asiniscalchi is right, it is a preprocessor macro that expands to ::eosio::string_to_name(#X) here.
If you are unfamiliar with preprocessor macros in C/C++ the # turns the argument into a string literal. For instance N(account) becomes ::eosio::string_to_name("account")
For those landing here, looks like the link is now:
https://github.com/EOSIO/eos/blob/master/contracts/eosiolib/types.hpp
See:
/**
* @brief used to generate a compile time uint64_t from the base32 encoded string interpretation of X
* @ingroup types
*/
#define N(X) ::eosio::string_to_name(#X)
Most helpful comment
For those landing here, looks like the link is now:
https://github.com/EOSIO/eos/blob/master/contracts/eosiolib/types.hpp
See: