Artifact 9f11f8143f5626920f58d24d3a2566bbac66d55c72ea44f5f1480c9b6c7b78ff:

Wiki page [Features] by luismachuca 2019-02-16 16:38:40.
D 2019-02-16T16:38:40.877
L Features
P 4cc7468eebe08362cd43f6ce76a28178ae50e00e789c93ca1af1882cc225f942
U luismachuca
W 6467
The <b>[cxxomfort]</b> library adds various features that provide C++03, C++11 with partial support for features from later standards. For example, you can get some C++11 features in C++03, or C++14 features in C++11 (and sometimes even in C++03!). 

The featureset described here is automatically included when using <tt>#include <cxxomfort/cxxomfort.hpp></tt> or <tt>#include <cxxomfort/backports.hpp></tt>, but you can get a more granular control of features by including specific headers. In particular, there's a .hpp header for each Standard C++ header that has backports in the library .

<h2>Base Features</h2>

This is the base feature set that is always included automatically when you use this library. Most of it involves backporting to C++03 some features from C++11. If access to only these base features is desired for more granular control, include as follows:

<verbatim>
#include <cxxomfort/base.hpp>
</verbatim>

The base feature set comprises:

[#cxxo-nullptr|<tt>nullptr</tt> / null pointer literal] -- [#cxxo-static_assert|<tt>static_assert</tt>] -- [#cxxo-iterator|Iterator Helpers begin() and end()] -- [Features/explicit_cast|<tt>explicit_cast</tt> / explicit operator conversion emulation] -- [Features/MetaprogrammingHelpers|<tt>enable_if</tt> and <tt>conditional</tt>] -- [Features/rvref|Movable type emulation] -- [Features/integrals|Extended integral types]

<h2>Standard Features</h2>

This is the "normal" feature set, which basically consists of backporting or integrating features from selected C++ headers. In order to access these one can explicitly invoke cxxomfort.hpp or backports.hpp, or any of the more specific headers with the backports wanted.

<verbatim>
#include <cxxomfort/cxxomfort.hpp> // the entire library
#include <cxxomfort/backports.hpp> // C++ backports and minor assist only
</verbatim>

Features from:
<center> [/uv/html/std0algorithm.html|<algorithm>]  -- [/uv/html/std0array.html|<array>]  -- [/uv/html/std0cstddef.html|<cstddef>]  --  [/uv/html/std0cstdint.html|<cstdint>]  -- [/uv/html/std0cuchar.html|<cuchar>]  -- [/uv/html/std0forward_list.html|<forward_list>] -- [/uv/html/std0functional.html|<functional>] -- [/uv/html/std0limits.html|<limits>]  --  [/uv/html/std0memory.html|<memory>]  -- [/uv/html/std0numeric.html|<numeric>]  -- [/uv/html/std0random.html|<random>]  --  [/uv/html/std0string.html|<string>] -- [/uv/html/std0string_view.html|<string_view>]  --  [/uv/html/std0system_error.html|<system_error>]  --  [/uv/html/std0tuple.html|<tuple>]  -- [/uv/html/std0typeindex.html|<typeindex>]  -- [/uv/html/std0type_traits.html|<type traits>] -- [/uv/html/std0utility.html|<utility>]</center>

<h3>Other Features</h3>
The library also adds some of [Supplements|its own assortment of features] specific to cxxomfort - as in, not part of C++ revisions or proposals.

There's also utilities not included in the normal cxxomfort distribution, called [Extras].


<h2>Details of Base Features</h2>

Here follows a listing of features.

<h3><a name="base-nullptr"></a>Null pointer literal</h3>

Implemented by <tt>base.hpp</tt>.

C++11 defines a "null pointer literal" as a special keyword that can be used to explicitly indicate a null pointer and its type. This allows code relying on null pointers to implement null-specific features such as function overloads, as well as avoid ambiguities due to null-to-integral promotion. In C++11, this literal is named `nullptr`  and is [http://en.cppreference.com/w/cpp/language/nullptr|documented here], including usage examples. 

This library implements the null pointer literal in C++03 in the way recommended by the Standard (see also [http://en.wikibooks.org/wiki/More_C++_Idioms/nullptr#Solution_and_Sample_Code|Meyer's implementation]).

<b>Known limitations:</b>

  *  Requires the inclusion of a header to be used.
  *  Does not implement any operators beyond implicit conversion.

<hr/>
<h3><a name="base-static_assert"></a>Static Assert</h3>

Implements: n1604, [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html|n1720] for compile-time assertions into the language.<br/>

Implemented by <tt>base.hpp</tt>.

C++11 adds the capability to perform assertions at compile time via a special keyword. This allows code to test for prerequisites at compile-time and deliver better error messages.

The compile-time assertion feature in C++11 is [http://en.cppreference.com/w/cpp/language/static_assert|documented here], including usage samples.

The <code>static_assert</code> keyword is implemented in C++03 as a pseudo-keyword using a macro with the same syntax; however, being a macro, it has some limitations.

<b>Known limitations:</b>

  *  Can not take arguments containing comas - for those, wrapping parentheses, a typedef or an enum declaration are required (and recommended even in C++11 mode, as they make code clearer).
  *  The compiler won't be able to display the actual error message string, although it will at least point to its location (which, when using an IDE, should amount to the same effect).

<b>Non-backport assists:</b>

  *  Starting in <tt>version 0.42</tt>): the extra pseudokeyword <tt>static_assert0</tt> serves as a static assert without message, as per C++17/C++20.

<hr/>
<h3>Metaprogramming Helpers</h3>

Implementation of the helpers identity, enable_if, conditional.

Brief description:

<verbatim>
template <typename T> struct identity {
    typedef T type;
};
template <bool If, typename T> struct enable_if {
    defined_if(If) typedef T type;
};
template <bool If, typename A, typename B> struct conditional {
    defined_if(If) typedef A type;
    defined_else() typedef B type;
};
</verbatim>

The three are <b>unconditionally</b> added to namespace std.

<hr/>
<h3><a name="base-iterator"></a>Iterator Access Functions</h3>

Implemented by <tt>base.hpp</tt>. See also: https://en.cppreference.com/w/cpp/iterator .

The following interfaces are backported from C++11:

  *  <tt>std::begin</tt> and <tt>std::end</tt> -- generically find the begin and end iterators for a container-like expression.
  *  <tt>std::next</tt> and <tt>std::prev</tt> -- generically advance an iterator in forward or backward direction.

<hr/>

  *  [/uv/html/cxxomfort-behaviour.html|Behaviour Macros]
  *  [/uv/html/cxxo-sup.html|Library Supplements]
  *  [Extras]
  *  [Cxxomfort|Back to the beginning]


Z cc19d6c20339d25071ad113a913d5f26