Calling C++ "void foo(Klass&)"

Arjan via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 10 00:58:55 PDT 2017


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.
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 =
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.

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.

HTH




More information about the Digitalmars-d mailing list