Skip to content
Frank Columbo edited this page Jul 17, 2017 · 43 revisions

Constainer

Constainer provides a constexpr-capable set of container and algorithm templates with interfaces identical to STL- and Boost-containers.

constexpr auto str = ("Hello"_cstr + " co").replace(6, 2, "constexpr!")
                                         .append(2, '!').substr(0, 16);
static_assert( str == "Hello constexpr!" );

Features

String converters:

Containers:

  • Array, an std::array clone.
  • BasicVector, an std::vector clone.
  • BasicString, an std::basic_string clone.
  • Bitset, an efficient bitset with extra functionality
  • StableVector, a boost::container::stable_vector clone. List-like iterator stability meets random-access.
  • FlatSet, FlatMultiSet, FlatMap, FlatMultiMap, which are a mix of boost::container::flat_* and the standard associative containers. And don't forget the stable counterparts StableFlatSet, StableFlatMultiSet, StableFlatMap and StableFlatMultimap.

Algorithms, Iterators & Miscellaneous:

  • Algorithms as known from <algorithm> and <iterator>, and extensions (e.g. iota_n, find_first_not_of)
  • ADL-supporting range access functions, including begin/end (with r- and c- versions), size and decayed_begin/-end
  • Iterator adaptors: Fully implemented reverse_iterator, move_iterator and transform_iterator.
  • Iterator concepts
  • A few mathematical functions, including safeMul (floating point multiplication avoiding implicit overflows so as to preserve constexpr-ness), pow(Real, int), pow10(Real), normalization and floating point modulo
  • .. and more! Check out the test file for examples.

Compiler support

Compiler Support/Version Notes
Clang Yes: 3.7.1
Partially with 3.6.
Works partially with 3.6, has problems with stable containers though. See issue #1.
GCC Partially. See issues #2 and #3. Should probably be ready to work once both bugs are fixed. Static Printf works.
ICC No ICC doesn't properly support constexpr yet. It also ICEs on Constainer/Array.hxx (with 20150407).
VC++ No VC++ runs far behind GCC and Clang, missing fundamental features like extended constexpr and expression SFINAE.

Further notes: ICC is also incompatible because a (soon to be published) "static" version of printf requires string literal operator templates, which ICC does not support at the moment.

Disclaimer

Avoid usage of any entities in this library unless you need constant expressions. This library is in alpha state, only marginally tested and incomplete.

Clone this wiki locally