On Thursday, 10 August 2017 at 07:58:55 UTC, Arjan wrote:
On Thursday, 10 August 2017 at 00:32:40 UTC, Mengu wrote:
my second question is: i have no idea what's going on in this file: https://github.com/whoshuu/cpr/blob/master/include/cpr/body.h i'd appreciate some pointers.


A new 'type' named Body which IS-A std::string is defined.

i think we can mimic this with an alias this for a string (or const char*) property. is that right?

To construct a Body there are various options:
The ctors 'default': Body(), 'copy': Body(const Body&) and 'move': Body(Body&&) ctors are using the compiler generated default implementation.
The same is true for the assignment operators =

how can i check what compiler generates for default so i can add them to my extern C++ clause?

Then a few explicit conversion ctors are defined to construct a Body from a const char* string and std::string. Explicit means the compiler is not allowed to implicit convert to std::string or const char* for provide args not being a const char* or std::string but for which a conversion exists.


i'll give these converters a try.


Since the h file also contains the definitions, the compiler must inline the code for the Body ctors and assignment operator. It also means not C/cpp file is needed since the function bodies are already in the h file.

i realized that when i saw the member initialization syntax in header files.


HTH

thank you very much for the detailed explanation.

Reply via email to