cxxomfort  rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
Macros
Code Generation

Describes cxxomfort macros for code generation. More...

Macros

#define CXXO_DEFAULT_DEFAULT_CONSTRUCTOR(Type)   Type () = default [or equivalent]
 Declares a “ =default ” default constructor. More...
 
#define CXXO_DEFAULT_COPY_CONSTRUCTOR(Type, Su, ...)
 Declares a =default copy constructor. More...
 
#define CXXO_TYPEOF(expr)   __typeof__(expr) [or equivalent]
 Obtains the type of expr if there is a __typeof__-like facility to do so. More...
 
#define CXXO_STRINGIZE(...)   CXXO_STRINGIZE_IMPL(__VA_ARGS__)
 
#define CXXO_STRINGIZE1(x)   CXXO_STRINGIZE1_IMPL1(x)
 
#define CXXO_JOIN(x, y)   CXXO_JOIN_IMPL1(x,y)
 

Detailed Description

Describes cxxomfort macros for code generation.

Cxxomfort includes a number of macros that help generate code. This includes in particular code constructs that can change across C++ Standard versions, such as noexcept conditionals, constructors definition, and sequence construction.

For generating code for types and classes:

For generating functions:

Including #include <cxxomfort/base.hpp> (explicitly or implicitly) gives access to the following macros:

Including #include <cxxomfort/impl/relationals.hpp> gives access to the following feature:

For evaluating expressions:

Including #include <cxxomfort/library/i12n.hpp> (explicitly or implicitly) gives access to the sequence intialization helper macros :

Macro Definition Documentation

◆ CXXO_DEFAULT_DEFAULT_CONSTRUCTOR

#define CXXO_DEFAULT_DEFAULT_CONSTRUCTOR (   Type)    Type () = default [or equivalent]

Declares a “ =default ” default constructor.

Codegen:

Using this macro in the body of a class will invoke, where available, the =default default constructor. In pre-C++11, it will invoke a throw() empty constructor.

class Foo {
//In >= C++11 equivalent to:
Foo () noexcept = default;
};

◆ CXXO_DEFAULT_COPY_CONSTRUCTOR

#define CXXO_DEFAULT_COPY_CONSTRUCTOR (   Type,
  Su,
  ... 
)
Value:
[if >=C++11] Type (Type const& ) Su = default \
[else] Type (Type const& From) Su : __VA_ARGS__ {}

Declares a =default copy constructor.

Parameters
Suconstructor suffix (eg.: noexcept)
...Explicit constructor body (for C++03)
Codegen:

Using this macro in the body of a class invokes, starting with C++11, a =default copy constructor. In C++03, it generates the code for a copy constructor using the subsequent arguments to the macro as code for the member initializer list, using the variable name From for the argument of the copy constructor.

class Foo {
CXXO_DEFAULT_COPY_CONSTRUCTOR(Foo, , member(From.member) );
//In >= C++11 equivalent to:
Foo (Foo const&) = default;
//In < C++11 equivalent to:
Foo (Foo const& From) : member(From.member) {}
private:
float member;
};

◆ CXXO_TYPEOF

#define CXXO_TYPEOF (   expr)    __typeof__(expr) [or equivalent]

Obtains the type of expr if there is a __typeof__-like facility to do so.

Parameters
exprAn expression evaluating to a type. Since this is a macro, it can't take commas.

In C++11 onwards, this evaluates to decltype(expr) ; in other modes, it will ealuate to __typeof__(expr) if the feature is available or will error out if not.

Referenced by cxxomfort::cxxostd::bind_front().

◆ CXXO_STRINGIZE

#define CXXO_STRINGIZE (   ...)    CXXO_STRINGIZE_IMPL(__VA_ARGS__)

Stringizes passed (transforms them into a string literal)

◆ CXXO_STRINGIZE1

#define CXXO_STRINGIZE1 (   x)    CXXO_STRINGIZE1_IMPL1(x)

Stringizes a single token (transforms it into a string literal)

◆ CXXO_JOIN

#define CXXO_JOIN (   x,
 
)    CXXO_JOIN_IMPL1(x,y)

Joins two tokens