D 2019-01-01T15:01:57.238 L Extras P f8c6b5a6ca27228b58cfa863d2b4c1ecd2a4b344 U luismachuca W 4550 Besides the [Features|normal features] that are activated automatically upon inclusion of the library, as well as the [Supplements], there are a number of side-projects that don't count as part of cxxomfort's distribution proper. They are being developed separately and rather than integrate with cxxomfort tightly they just depend on the library as a whole. The idea is to pick a number of features, proposals or general C++ concepts and implement them separately. There are a number of reasons to tackle these features separately: * the syntax to implement them is too different to C++'s normal syntax (heavy macros, etc) or is too heavy. * the feature is more advanced or convoluted and benefits from being decoupled from most cxxomfort internals. * the feature is heavily compiler-dependent. * the feature is not standardized yet and/or present only as a proposal. In order to use these features, they can be cloned or downloaded from their specific repositories. Last update of this listing: November 2018
cxxomfort/extras/auto.hpp
. CXXOMFORT_USING_auto
is defined.
This header adds the following macros:
CXXO_AUTO( variablename, expr ) CXXO_DECLTYPE( expr )The above macros allow for emulation of C++11's new "auto" and "decltype" semantics if the compiler supports an equivalent semantic such as typeof in C++03 mode (as GCC's
__typeof__
). Usage is very simple:
typdef std::listIn C++11, the macros extend simply toSHL_t; // short-list type SHL_t shl; ... CXXO_AUTO (M, shl.size() ); // M is automatically declared as eg.: an unsigned int in this case ... cout<< M<< endl;
auto variablename = expr
and decltype(expr)
respectively.
In C++03, the macros extend to a compiler-supported "typeof" invocation; if none is available, compilation fails with an error messaage of "typeof not supported
".
Requirements:
* In non-C++11 mode, the compiler must support a keyword like __typeof__.
Known Limitations:
* This feature works in Microsoft C++ ≥ 8.0 thanks to a combination of documented hacks for typeof emulation; however, in this case it can not be used in all the contexts a normal __typeof__
can, so use with caution.
* When in C++03 mode, remember "typeof" intrinsics may not resolve reference types the same way C++11's decltype does.
equal
, mismatch
and the find_*
family of algorithms.