0

The code snippet for this question is from the Persistance API section of the WIKI documentation for EOS. The link to this page is here...

https://github.com/EOSIO/eos/wiki/Persistence-API

In the following code snippet, it looks like the class template (or template class) is being typedef'd as service_table_type. Then a whole bunch of custom types are passed within the angle brackets of the class template and there seems to be nothing new there apart from the complexity (if i understood it correctly).

using service_table_type = multi_index<service, service_rec,
indexed_by< N(bycustomer), const_mem_fun<service_rec, account_name, 
&service_rec::get_customer>>>;

My question is regarding the below line line of code that follows the above code snippet. what is going on here? it looks like a call to the function service_table() which returns a parameter of type service_table_type. From where did this function come from? If this function came from a library, how would it return the value of type service_table_type which we arbitrarily created?

service_table_type service_table( current_receiver(), mechanic );

could you provide me a stripped down generic code example of what's going on here?

Thank you kindly!

kamiss
  • 45
  • 1
  • 5

1 Answers1

0

You are calling constructor of multi_index class. service_table is the variable name

pure cuteness
  • 1,635
  • 11
  • 26
  • Thanks for the reply. To test my understanding, I wrote a Test class which, to my understanding, mimics what's going on in the above code. My code works the way it is but when i include the lines commented out, it doesn't work. ( here i am assuming that the commented lines are analogous to: " using service_table_type = multi_index – kamiss Jun 20 '18 at 12:46
  • Sorry my edit timed out so I couldn't properly structure the above question. Here is the code that works as is. the commented out section doesn't work. what am i not doing that the example above is doing? template class Test{ private: T x; public: Test(T templateVar){std::cout<; //xxx obj(25.003); Test obj(25.003); return 0; }` – kamiss Jun 20 '18 at 13:01
  • What you mean by "it doesn't work"? It doesn't compile? Check that you've enabled C++11. Alternatively you may change `using xxx = Test` to `typedef Test xxx;` – pure cuteness Jun 20 '18 at 13:32