• Stars
    star
    393
  • Rank 109,518 (Top 3 %)
  • Language
    C++
  • License
    Boost Software Li...
  • Created almost 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

optional lite - A C++17-like optional, a nullable object for C++98, C++11 and later in a single-file header-only library

optional lite: A single-file header-only version of a C++17-like optional, a nullable object for C++98, C++11 and later

Language License Build Status Build status Version download Conan Try it online Try it on godbolt online

Contents

Example usage

#include "nonstd/optional.hpp"

#include <cstdlib>
#include <iostream>

using nonstd::optional;
using nonstd::nullopt;

optional<int> to_int( char const * const text )
{
    char * pos = NULL;
    const int value = strtol( text, &pos, 0 );

    return pos == text ? nullopt : optional<int>( value );
}

int main( int argc, char * argv[] )
{
    char const * text = argc > 1 ? argv[1] : "42";

    optional<int> oi = to_int( text );

    if ( oi ) std::cout << "'" << text << "' is " << *oi;
    else      std::cout << "'" << text << "' isn't a number";
}

Compile and run

prompt>g++ -Wall -Wextra -std=c++03 -I../include -o 01-to_int.exe 01-to_int.cpp && 01-to_int x1
'x1' isn't a number

In a nutshell

optional lite is a single-file header-only library to represent optional (nullable) objects and pass them by value. The library aims to provide a C++17-like optional for use with C++98 and later. If available, std::optional is used. There's also a simpler version, optional bare. Unlike optional lite, optional bare is limited to default-constructible and copyable types.

Features and properties of optional lite are ease of installation (single header), freedom of dependencies other than the standard library and control over object alignment (if needed). optional lite shares the approach to in-place tags with any-lite, expected-lite and with variant-lite and these libraries can be used together.

Not provided are reference-type optionals. optional lite doesn't handle overloaded address of operators.

For more examples, see this answer on StackOverflow [8] and the quick start guide [9] of Boost.Optional (note that its interface differs from optional lite).

License

optional lite is distributed under the Boost Software License.

Dependencies

optional lite has no other dependencies than the C++ standard library.

Installation

optional lite is a single-file header-only library. Put optional.hpp in the include folder directly into the project source tree or somewhere reachable from your project.

Or, if you use the conan package manager, you might follow these steps:

  1. Create source file ./main.cpp, e.g. with the contents of the example code above.

  2. Create ./conanfile.txt file with a reference to variant-lite in the requires section:

    [requires]
    optional-lite/3.2.0  # 3.3.0 when available
    
    [generators]
    cmake
    
  3. Create ./CMakeLists.txt:

    cmake_minimum_required(VERSION 3.1)
    project(optional-example CXX)
    
    include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
    conan_basic_setup()
    
    add_executable(${PROJECT_NAME} main.cpp)
    target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
  4. Run the following commands:

    mkdir build && cd build
    conan install .. --settings arch=x86 --settings compiler=gcc
    cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
    cmake --build . --config Release
    

Synopsis

Contents
Types in namespace nonstd
Interface of optional lite
Algorithms for optional lite
Configuration

Types and values in namespace nonstd

Purpose Type / value Object
To be, or not template< typename T >
class optional;
Β 
Disengaging struct nullopt_t; nullopt_t nullopt;
Error reporting class bad_optional_access; Β 
In-place construction struct in_place_tag Β 
Β  in_place select type or index for in-place construction
Β  in_place_type select type for in-place construction
 (variant) in_place_index select index for in-place construction
Β  nonstd_lite_in_place_type_t( T) macro for alias template in_place_type_t<T>
 (variant) nonstd_lite_in_place_index_t( T ) macro for alias template in_place_index_t<T>

Interface of optional lite

nonstd::optional provides the non-standard method value_or_eval(). Its presence can be controlled via optional_CONFIG_NO_EXTENSIONS, see section Configuration.

Kind Std Method Result
Construction Β  optional() noexcept default construct a nulled object
Β  Β  optional( nullopt_t ) noexcept explicitly construct a nulled object
Β  Β  optional( optional const & rhs ) move-construct from an other optional
Β  C++11 optional( optional && rhs ) noexcept(...) move-construct from an other optional
Β  Β  optional( value_type const & value ) copy-construct from a value
Β  C++11 optional( value_type && value ) move-construct from a value
Β  C++11 explicit optional( in_place_type_t<T>, Args&&... args ) in-place-construct type T
Β  C++11 explicit optional( in_place_type_t<T>, std::initializer_list<U> il, Args&&... args ) in-place-construct type T
Destruction Β  ~optional() destruct current content, if any
Assignment Β  optional & operator=( nullopt_t ) null the object;
destruct current content, if any
Β  Β  optional & operator=( optional const & rhs ) copy-assign from other optional;
destruct current content, if any
Β  C++11 optional & operator=( optional && rhs ) move-assign from other optional;
destruct current content, if any
Β  C++11 template< class U, ...>
**optional & operator=( U && v )
move-assign from a value;
destruct current content, if any
Β  C++11 template< class... Args >
T & emplace( Args&&... args )
emplace type T
Β  C++11 template< class U, class... Args >
T & emplace( std::initializer_list<U> il, Args&&... args )
emplace type T
Swap Β  void swap( optional & rhs ) noexcept(...) swap with rhs
Content Β  value_type const * operator ->() const pointer to current content (const);
must contain value
Β  Β  value_type * operator ->() pointer to current content (non-const);
must contain value
Β  Β  value_type const & operator *() & the current content (const ref);
must contain value
Β  Β  value_type & operator *() & the current content (non-const ref);
must contain value
Β  C++11 value_type const & operator *() && the current content (const ref);
must contain value
Β  C++11 value_type & operator *() && the current content (non-const ref);
must contain value
State Β  operator bool() const true if content is present
Β  Β  bool has_value() const true if content is present
Β  Β  value_type const & value() & the current content (const ref);
throws bad_optional_access if nulled
Β  Β  value_type & value() & the current content (non-const ref);
throws bad_optional_access if nulled
Β  C++11 value_type const & value() && the current content (const ref);
throws bad_optional_access if nulled
Β  C++11 value_type & value() && the current content (non-const ref);
throws bad_optional_access if nulled
Β  <C++11 value_type value_or(
value_type const & default_value ) const
the value, or default_value if nulled
value_type must be copy-constructible
Β  C++11 value_type value_or(
value_type && default_value ) &
the value, or default_value if nulled
value_type must be copy-constructible
Β  C++11 value_type value_or(
value_type && default_value ) &&
the value, or default_value if nulled
value_type must be copy-constructible
Β  <C++11 template<typename F>
value_type value_or_eval(F f) const
the value, or function call result if nulled
non-standard extension
Β  C++11 template<typename F>
value_type value_or_eval(F f) &
the value, or function call result if nulled
non-standard extension
Β  C++11 template<typename F>
value_type value_or_eval(F f) &&
the value, or function call result if nulled
non-standard extension
Modifiers Β  void reset() noexcept make empty

Algorithms for optional lite

Kind Std Function
Relational operators Β  Β 
== Β  template< typename T >
bool operator==( optional const & x, optional const & y )
!= Β  template< typename T >
bool operator!=( optional const & x, optional const & y )
< Β  template< typename T >
bool operator<( optional const & x, optional const & y )
> Β  template< typename T >
bool operator>( optional const & x, optional const & y )
<= Β  template< typename T >
bool **operator<=*( optional const & x, optional const & y )
>= Β  template< typename T >
bool **operator>=*( optional const & x, optional const & y )
Comparison with nullopt Β  Β 
== Β  template< typename T >
bool operator==( optional const & x, nullopt_t ) noexcept
Β  Β  template< typename T >
bool operator==( nullopt_t, optional const & x ) noexcept
!= Β  template< typename T >
bool operator!=( optional const & x, nullopt_t ) noexcept
Β  Β  template< typename T >
bool operator!=( nullopt_t, optional const & x ) noexcept
< Β  template< typename T >
bool operator<( optional const &, nullopt_t ) noexcept
Β  Β  template< typename T >
bool operator<( nullopt_t, optional const & x ) noexcept
<= Β  template< typename T >
bool operator<=( optional const & x, nullopt_t ) noexcept
Β  Β  template< typename T >
bool operator<=( nullopt_t, optional const & ) noexcept
> Β  template< typename T >
bool operator>( optional const & x, nullopt_t ) noexcept
Β  Β  template< typename T >
bool operator>( nullopt_t, optional const & ) noexcept
>= Β  template< typename T >
bool operator>=( optional const &, nullopt_t ) noexcept
Β  Β  template< typename T >
bool operator>=( nullopt_t, optional const & x ) noexcept
Comparison with T Β  Β 
== Β  template< typename T >
bool operator==( optional const & x, const T& v )
Β  Β  template< typename T >
bool operator==( T const & v, optional const & x )
!= Β  template< typename T >
bool operator!=( optional const & x, const T& v )
Β  Β  template< typename T >
bool operator!=( T const & v, optional const & x )
< Β  template< typename T >
bool operator<( optional const & x, const T& v )
Β  Β  template< typename T >
bool operator<( T const & v, optional const & x )
<= Β  template< typename T >
bool operator<=( optional const & x, const T& v )
Β  Β  template< typename T >
bool operator<=( T const & v, optional const & x )
> Β  template< typename T >
bool operator>( optional const & x, const T& v )
Β  Β  template< typename T >
bool operator>( T const & v, optional const & x )
>= Β  template< typename T >
bool operator>=( optional const & x, const T& v )
Β  Β  template< typename T >
bool operator>=( T const & v, optional const & x )
Specialized algorithms Β  Β 
swap Β  template< typename T >
void swap( optional & x, optional & y ) noexcept(...)
create <C++11 template< typename T >
optional<T> make_optional( T const & v )
Β  C++11 template< class T >
optional< typename std::decay<T>::type > make_optional( T && v )
Β  C++11 template< class T, class...Args >
optional<T> make_optional( Args&&... args )
Β  C++11 template< class T, class U, class... Args >
optional<T> make_optional( std::initializer_list<U> il, Args&&... args )
hash C++11 template< class T >
class hash< nonstd::optional<T> >

Configuration

Tweak header

If the compiler supports __has_include(), optional lite supports the tweak header mechanism. Provide your tweak header as nonstd/optional.tweak.hpp in a folder in the include-search-path. In the tweak header, provide definitions as documented below, like #define optional_CPLUSPLUS 201103L.

Standard selection macro

-Doptional_CPLUSPLUS=199711L
Define this macro to override the auto-detection of the supported C++ standard, if your compiler does not set the __cplusplus macro correctly.

Select std::optional or nonstd::optional

At default, optional lite uses std::optional if it is available and lets you use it via namespace nonstd. You can however override this default and explicitly request to use std::optional or optional lite's nonstd::optional as nonstd::optional via the following macros.

-Doptional_CONFIG_SELECT_OPTIONAL=optional_OPTIONAL_DEFAULT
Define this to optional_OPTIONAL_STD to select std::optional as nonstd::optional. Define this to optional_OPTIONAL_NONSTD to select nonstd::optional as nonstd::optional. Default is undefined, which has the same effect as defining to optional_OPTIONAL_DEFAULT.

Disable extensions

-Doptional_CONFIG_NO_EXTENSIONS=0
Define this to 1 if you want to compile without extensions. Default is undefined.

Disable exceptions

-Doptional_CONFIG_NO_EXCEPTIONS=0
Define this to 1 if you want to compile without exceptions. If not defined, the header tries and detect if exceptions have been disabled (e.g. via -fno-exceptions). Default is undefined.

Macros to control alignment

If optional lite is compiled as C++11 or later, C++11 alignment facilities are used for storage of the underlying object. When compiled as pre-C++11, optional lite tries to determine proper alignment itself. If this doesn't work out, you can control alignment via the following macros. See also section Implementation notes.

-Doptional_CONFIG_MAX_ALIGN_HACK=0
Define this to 1 to use the max align hack for alignment. Default is 0.

-Doptional_CONFIG_ALIGN_AS=pod-type
Define this to the pod-type you want to align to (no default).

-Doptional_CONFIG_ALIGN_AS_FALLBACK=pod-type
Define this to the pod-type to use for alignment if the algorithm of optional lite cannot find a suitable POD type to use for alignment. Default is double.

Comparison of std::optional, optional lite and Boost.Optional

optional lite is inspired on std::optional, which in turn is inspired on Boost.Optional. Here are the significant differences.

Aspect std::optional optional lite Boost.Optional
Move semantics yes C++11 no
noexcept yes C++11 no
Hash support yes C++11 no
Throwing value accessor yes yes no
Literal type partially C++11/14 no
In-place construction emplace, tag in_place emplace, tag in_place utility in_place_factory
Disengaged state tag nullopt nullopt none
optional references no no yes
Conversion from optional<U>
to optional<T>
no no yes
Duplicated interface functions 1) no no yes
Explicit convert to ptr (get_ptr) no no yes
  1. is_initialized(), reset(), get().

Reported to work with

The table below mentions the compiler versions optional lite is reported to work with.

OS Compiler Versions
Windows Clang/LLVM ?
Β  GCC 5.2.0
Β  Visual C++
(Visual Studio)
8 (2005), 10 (2010), 11 (2012),
12 (2013), 14 (2015), 14 (2017)
GNU/Linux Clang/LLVM 3.5.0, 3.6.0, 7.0.0
Β  GCC 4.8.4, 5, 6, 8
Β  ICC 19
macOS Xcode 8.3, 9, 10, 11

Building the tests

To build the tests you need:

The lest test framework is included in the test folder.

The following steps assume that the optional lite source code has been cloned into a directory named c:\optional-lite.

  1. Create a directory for the build outputs for a particular architecture. Here we use c:\optional-lite\build-win-x86-vc10.

     cd c:\optional-lite
     md build-win-x86-vc10
     cd build-win-x86-vc10
    
  2. Configure CMake to use the compiler of your choice (run cmake --help for a list).

     cmake -G "Visual Studio 10 2010" -DOPTIONAL_LITE_OPT_BUILD_TESTS=ON ..
    
  3. Build the test suite in the Debug configuration (alternatively use Release).

     cmake --build . --config Debug
    
  4. Run the test suite.

     ctest -V -C Debug
    

All tests should pass, indicating your platform is supported and you are ready to use optional lite.

Implementation notes

Object allocation and alignment

optional lite reserves POD-type storage for an object of the underlying type inside a union to prevent unwanted construction and uses placement new to construct the object when required. Using non-placement new (malloc) to obtain storage, ensures that the memory is properly aligned for the object's type, whereas that's not the case with placement new.

If you access data that's not properly aligned, it 1) may take longer than when it is properly aligned (on x86 processors), or 2) it may terminate the program immediately (many other processors).

Although the C++ standard does not guarantee that all user-defined types have the alignment of some POD type, in practice it's likely they do [8, part 2].

If optional lite is compiled as C++11 or later, C++11 alignment facilities are used for storage of the underlying object. When compiling as pre-C++11, optional lite tries to determine proper alignment using meta programming. If this doesn't work out, you can control alignment via three macros.

optional lite uses the following rules for alignment:

  1. If the program compiles as C++11 or later, C++11 alignment facilities are used.

  2. If you define -Doptional_CONFIG_MAX_ALIGN_HACK=1 the underlying type is aligned as the most restricted type in struct max_align_t. This potentially wastes many bytes per optional if the actually required alignment is much less, e.g. 24 bytes used instead of the 2 bytes required.

  3. If you define -Doptional_CONFIG_ALIGN_AS=pod-type the underlying type is aligned as pod-type. It's your obligation to specify a type with proper alignment.

  4. If you define -Doptional_CONFIG_ALIGN_AS_FALLBACK=pod-type the fallback type for alignment of rule 5 below becomes pod-type. It's your obligation to specify a type with proper alignment.

  5. At default, optional lite tries to find a POD type with the same alignment as the underlying type.

    The algorithm for alignment of 5. is:

    • Determine the alignment A of the underlying type using alignment_of<>.
    • Find a POD type from the list alignment_types with exactly alignment A.
    • If no such POD type is found, use a type with a relatively strict alignment requirement such as double; this type is specified in optional_CONFIG_ALIGN_AS_FALLBACK (default double).

Note that the algorithm of 5. differs from the one Andrei Alexandrescu uses in [8, part 2].

The class template alignment_of<> is gleaned from Boost.TypeTraits, alignment_of [11]. The storage type storage_t<> is adapted from the one I created for spike-expected, expected lite [13].

For more information on constructed unions and alignment, see [8-12].

Other implementations of optional

Notes and references

[1] CppReference. Optional.

[2] ISO/IEC WG21. N4606, section 20.6 Optional objects. July 2016.

[3] Fernando Cacciola, Andrzej KrzemieΕ„ski. A proposal to add a utility class to represent optional objects (Revision 5).

[4] Andrzej KrzemieΕ„ski. optional (nullable) objects for C++14. Reference implementation on GitHub.

[5] Simon Brand. P0798R0: Monadic operations for std::optional.

[6] Simon Brand. C++11/14/17 std::optional with functional-style extensions . Reference implementation on GitHub.

[7] Fernando Cacciola. Boost.Optional library.

[8] StackOverflow. How should one use std::optional?. Answer by Timothy Shields. 31 May 2013.

[9] Fernando Cacciola. Boost.Optional Quick start guide.

[10] Andrei Alexandrescu. Generic: Discriminated Unions part 1, part 2, part 3. April 2002.

[11] Herb Sutter. Style Case Study #3: Construction Unions. GotW #85. 2009

[12] Kevin T. Manley. Using Constructed Types in C++ Unions. C/C++ Users Journal, 20(8), August 2002.

[13] StackOverflow. Determining maximum possible alignment in C++.

[14] Boost.TypeTraits, alignment_of ( code ).

[15] Martin Moene. spike-expected (expected-lite.hpp).

Appendix

A.1 Compile-time information

The version of optional lite is available via tag [.version]. The following tags are available for information on the compiler and on the C++ standard library used: [.compiler], [.stdc++], [.stdlanguage] and [.stdlibrary].

A.2 Optional Lite test specification

click to expand

union: A C++03 union can only contain POD types
optional: Allows to default construct an empty optional (1a)
optional: Allows to explicitly construct a disengaged, empty optional via nullopt (1b)
optional: Allows to default construct an empty optional with a non-default-constructible (1a)
optional: Allows to copy-construct from empty optional (2)
optional: Allows to move-construct from empty optional (C++11, 3)
optional: Allows to copy-construct from empty optional, explicit converting (C++11, 4a)
optional: Allows to copy-construct from empty optional, non-explicit converting (4b)
optional: Allows to move-construct from empty optional, explicit converting (C++11, 5a)
optional: Allows to move-construct from empty optional, non-explicit converting (C++11, 5a)
optional: Allows to copy-construct from non-empty optional (2)
optional: Allows to copy-construct from non-empty optional, explicit converting (C++11, 4a)
optional: Allows to copy-construct from non-empty optional, non-explicit converting (4b)
optional: Allows to move-construct from non-empty optional (C++11, 3)
optional: Allows to move-construct from non-empty optional, explicit converting (C++11, 5a)
optional: Allows to move-construct from non-empty optional, non-explicit converting (C++11, 5b)
optional: Allows to copy-construct from literal value (8)
optional: Allows to copy-construct from literal value, converting (8)
optional: Allows to copy-construct from value (8)
optional: Allows to copy-construct from value, converting (8)
optional: Allows to move-construct from value (C++11, 8b)
optional: Allows to move-construct from value, explicit converting (C++11, 8a)
optional: Allows to move-construct from value, non-explicit converting (C++11, 8b)
optional: Allows to in-place construct an immovable object (C++11, 6
optional: Allows to in-place construct from literal value (C++11, 6)
optional: Allows to in-place construct from literal value (C++11, 6, const)
optional: Allows to in-place copy-construct from value (C++11, 6)
optional: Allows to in-place copy-construct from value (C++11, 6, const)
optional: Allows to in-place move-construct from value (C++11, 6)
optional: Allows to in-place copy-construct from initializer-list (C++11, 7)
optional: Allows to in-place copy-construct from initializer-list (C++11, 7, const)
optional: Allows to in-place move-construct from initializer-list (C++11, 7)
optional: Allows to assign nullopt to disengage (1)
optional: Allows to copy-assign from/to engaged and disengaged optionals (2)
optional: Allows to move-assign from/to engaged and disengaged optionals (C++11, 3)
optional: Allows to copy-assign from/to engaged and disengaged optionals, converting, (5)
optional: Allows to move-assign from/to engaged and disengaged optionals, converting (C++11, 6)
optional: Allows to copy-assign from literal value (4)
optional: Allows to copy-assign from value (4)
optional: Allows to move-assign from value (C++11, 4)
optional: Allows to copy-emplace content from arguments (C++11, 7)
optional: Allows to copy-emplace content from arguments (C++11, 7, const)
optional: Allows to move-emplace content from arguments (C++11, 7)
optional: Allows to copy-emplace content from intializer-list and arguments (C++11, 8)
optional: Allows to copy-emplace content from intializer-list and arguments (C++11, 8, const)
optional: Allows to move-emplace content from intializer-list and arguments (C++11, 8)
optional: Allows to swap with other optional (member)
optional: Allows to obtain value via operator->()
optional: Allows to obtain moved-value via operator->() (C++11)
optional: Allows to obtain value via operator*()
optional: Allows to obtain moved-value via operator*() (C++11)
optional: Allows to obtain has_value() via operator bool()
optional: Allows to obtain value via value()
optional: Allows to obtain moved-value via value() (C++11)
optional: Allows to obtain value or default via value_or()
optional: Allows to obtain moved-value or moved-default via value_or() (C++11)
optional: Allows to obtain value or function call result via value_or_eval() [extension]
optional: Allows to obtain moved-value or function call result via value_or_eval() (C++11) [extension]
optional: Throws bad_optional_access at disengaged access
optional: Throws bad_optional_access with non-empty what()
optional: Allows to reset content
optional: Ensure object is destructed only once (C++11)
optional: Ensure balanced construction-destruction (C++98)
optional: Allows to swaps engage state and values (non-member)
optional: Provides relational operators (non-member)
optional: Provides mixed-type relational operators (non-member)
make_optional: Allows to copy-construct optional
make_optional: Allows to move-construct optional (C++11)
make_optional: Allows to in-place copy-construct optional from arguments (C++11)
make_optional: Allows to in-place move-construct optional from arguments (C++11)
make_optional: Allows to in-place copy-construct optional from initializer-list and arguments (C++11)
make_optional: Allows to in-place move-construct optional from initializer-list and arguments (C++11)
std::hash<>: Allows to obtain hash (C++11)
tweak header: reads tweak header if supported [tweak]

More Repositories

1

span-lite

span lite - A C++20-like span for C++98, C++11 and later in a single-file header-only library
C++
495
star
2

lest

A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)
C++
366
star
3

string-view-lite

string_view lite - A C++17-like string_view for C++98, C++11 and later in a single-file header-only library
C++
364
star
4

expected-lite

expected lite - Expected objects in C++11 and later in a single-file header-only library
C++
274
star
5

variant-lite

variant lite - A C++17-like variant, a type-safe union for C++98, C++11 and later in a single-file header-only library
C++
230
star
6

ring-span-lite

ring-span lite - A C++yy-like ring_span type for C++98, C++11 and later in a single-file header-only library
C++
136
star
7

any-lite

any lite - A C++17-like any, a type-safe container for single values of any type for C++98, C++11 and later in a single-file header-only library
C++
123
star
8

PhysUnits-CT-Cpp11

A small C++11, C++14 header-only library for compile-time dimensional analysis and unit/quantity manipulation and conversion
C++
77
star
9

nonstd-lite

Parent of *-lite repositories, a migration path to post-C++11 features for pre-C++11 environments
Batchfile
68
star
10

clue

A tiny single-file header-only C++ logging framework
C++
56
star
11

jthread-lite

C++20's jthread for C++11 and later in a single-file header-only library
C++
53
star
12

expected-dark

Expected objects for C++11 and later (and later perhaps C++98 )
C++
52
star
13

byte-lite

byte lite - A C++17-like byte type for C++98, C++11 and later in a single-file header-only library
C++
51
star
14

value-ptr-lite

value-ptr-lite - A C++ smart-pointer with value semantics for C++98, C++11 and later in a single-file header-only library
C++
44
star
15

observer-ptr-lite

observer-ptr - An observer_ptr for C++98 and later in a single-file header-only library (Extensions for Library Fundamentals, v2, v3)
C++
36
star
16

scope-lite

A migration path to C++ library extensions scope_exit, scope_fail, scope_success, unique_resource
C++
34
star
17

type-lite

type - Strong types for C++98, C++11 and later in a single-file header-only library
C++
34
star
18

bit-lite

bit-lite - C++20 bit operations for C++98 and later in a single-file header-only library
C++
33
star
19

martin-moene.blogspot.com

Code from my Blog
C++
30
star
20

invoke-lite

A single-file header-only version of C++17-like invoke() for C++98, C++11 and later
C++
29
star
21

catch-lest-other-comparison

Tabularised feature comparison between Catch, doctest and lest C++ test frameworks
23
star
22

kalman-estimator

kalman-estimator - a Kalman estimator in C++
C++
22
star
23

string-lite

String facilities for C++98 and later - a library in search of its identity.
C++
19
star
24

optional-bare

optional bare - A simple version of a C++17-like optional for default-constructible, copyable types, for C++98 and later in a single-file header-only library
C++
18
star
25

spike-expected

expected: kind of optional?
HTML
16
star
26

status-value-lite

status-value - A class for status and optional value for C++11 and later, C++98 variant provided in a single-file header-only library
C++
14
star
27

atomic-lite

atomic lite - a C++11 atomic operations library for C++98 and later
C++
12
star
28

PhysUnits-RT

A C++ header-only library for run-time dimensional analysis and unit/quantity manipulation and conversion
C++
11
star
29

PhysUnits-CT

A C++ header-only library for compile-time dimensional analysis and unit/quantity manipulation and conversion
C++
11
star
30

WholeValue

Whole value idiom made easy in C++
C++
8
star
31

optional-fun-lite

optional-fun lite - Functional algorithms for optional (lite) for C++98, C++11 and later in a single-file header-only library
C++
6
star
32

EngFormat-Cpp

C++ based Engineering Notation Formatter
C++
6
star
33

indirect-value-lite

indirect_value lite – An indirect value-type for C++11 and later in a single-file header-only library (p1950)
C++
6
star
34

ACCUConf2016

Slides and other materials from ACCU Conference 2016
5
star
35

array_view2d

A simple 2D view on an array or vector for C++98 and C++11
C++
5
star
36

clamp

Limit a value or a range of values to fall between two extremes
C++
4
star
37

boolean-lite

boolean lite: A strong boolean type for C++98 and later
C++
4
star
38

svn-churn

A simple Python script to determine file churn and fix count of a Subversion repository.
Python
3
star
39

active-lite

Active objects
CMake
2
star
40

clamp-proposal

Propose clamp for C++ standard
CSS
2
star
41

kalman-estimator-ada

kalman-estimator - a Kalman estimator in Ada, sibling of Kalman estimator in C++
Makefile
2
star
42

nonstd-lite-project

Stuff common to nonstd lite repositories
CMake
2
star
43

Test-Normalised

1
star
44

bibliography

My bookshelf
TeX
1
star
45

hamlest

Matchers for lest
C++
1
star
46

wordindex

wordindex: create a linenumber cross-referenced list of words
C++
1
star
47

Test-NonNormalised

1
star
48

wordindex-ranged

wordindex: create a linenumber cross-referenced list of words using C++20 std::ranges
C++
1
star
49

testdox

TestDox - generate a readable overview of test case names from the specified files.
Hack
1
star