Home

Awesome

Backport C++

Ubuntu Build Status macOS Build Status Windows Build Status Codacy Badge Coverage Status Github Issues <br> Github Releases Bintray Releases


Backport is an ongoing effort to bring modern C++ utilities to be compatible with C++11.

It is a header-only library that implements much of the functionality from C++14, C++17, and C++20 to be compatible with C++11. constexpr support is conditionally enabled based on the language setting of the compiler (e.g. if using C++14, more constexpr is available to the user than with C++11)

Table of Contents

Rationale

C++11 was release 9 years ago, and yet many organizations still have yet to move onto more modern releases. In some cases this is due to security reasons, in others it may be that the toolchains don't yet exist for more modern C++ support. In any case, much of the newer C++ library types don't actually require newer C++ language features -- but provide significant value to the developer by creating a new vocabulary that doesn't exist in prior versions.

Much of the newer utilities may also have parallels in Boost libraries, however many organizations are unable to adopt this -- either due to the domain being too constrained, or due to Boost being a large dependency to introduce.

As a result, this library exists as a standalone, header-only, dependency-free drop-in for newer standard library features from C++11, C++14, C++17, and C++20.

Features

C++20

StatusFeaturePaper(s)
bpstd::spanP0122R7<br> P1024R3<br> P1976R2<br> P0317R1
bpstd::to_addressP0653R2
✅ (1)bpstd::make_unique_for_overwriteP1020R1<br> P1973R1
bpstd::is_nothrow_convertibleP0758R1
  1. The papers also include make_shared_for_overwrite and allocate_shared_for_overwrite, but these are intentionally not implemented -- since it is impossible to implement efficiently without also authoring shared_ptr (since to join the node allocations requires internal support)
<!-- span --> <!-- to_address --> <!-- make_unique_for_overwrite --> <!-- is_nothrow_convertible -->

C++17

StatusFeaturePaper(s)
❌ (1)File SystemP0218R1<br> P0219R1<br> P0392R0<br> P0317R1
bpstd::optionalN3793
bpstd::anyN3804
bpstd::string_viewN3921
uniform container access (non-member size(), data(), etcN4280
bpstd::applyN3915
bpstd::make_from_tupleP0209R2
bpstd::as_constP0007R1
bpstd::variantP0088R3<br> P0032R3<br> P0393R3
bpstd::uncaught_exceptionsN4152<br> N4259
bpstd::byteP0298R3
bpstd::not_fnP0005R4
bpstd::invokeN4169
bpstd::void_tN3911
bpstd::bool_constantN4389
Traits for swappabilityP0185R1
🚧Polymorphic allocators and memory resourcesN3916
  1. See this answer in FAQ
<!-- file system --> <!-- optional --> <!-- variant --> <!-- any --> <!-- string_view --> <!-- uniform container access --> <!-- apply --> <!-- make_from_tuple --> <!-- as_const --> <!-- uncaught_exceptions --> <!-- byte --> <!-- not_fn --> <!-- invoke --> <!-- void_t --> <!-- bool_constant --> <!-- nothrow_swappable --> <!-- Polymorphic Allocators -->

C++14

StatusFeaturePaper(s)
Type alias versions of standard transformation traitsN3655
Transparent operator functors (bpstd::greater<>, etc)N3421
bpstd::tuple_element_tN3887
❌ (1)SFINAE-friendly bpstd::result_ofN3670
Addressing tuples by typeN3462
➖ (2)bpstd::is_finalLWG 2112
bpstd::is_null_pointerLWG 2247
bpstd::make_reverse_iteratorLWG 2285
bpstd::exchangeN3668
bpstd::make_uniqueN3656
Compile-time integer sequences (bpstd::integer_sequence)N3658
User-defined literals for standard library types (bpstd::chrono_literals, bpstd::string_literals)N3642
User-defined literals for bpstd::complex (bpstd::complex_literals)N3779
  1. Obsolete. Replaced by bpstd::invoke_result
  2. Not implementable without compiler support. Pre-C++14, requires specializations and will default to false_type
<!-- alias of transformation traits --> <!-- transparent operator functors --> <!-- tuple_element_t --> <!-- sfinae-friendly result_of --> <!-- addressing tuples by type --> <!-- is_final --> <!-- is_null_pointer --> <!-- make_reverse_iterator --> <!-- exchange --> <!-- make_unique --> <!-- compile-time integer_sequence --> <!-- user defined literals for complex --> <!-- user defined literals for chrono/string -->

FAQ

Where is std::filesystem?

This library aims to deliver a header-only solution to the many missing types that have been introduced in newer standard libraries. std::filesystem is a bit complicated to handle, since it introduces a dependency on the operating system being compiled against. Implementing std::filesystem will generally require conditional compilation, and -- for best practices -- separate source files in order to insulate use of system headers (lest this library introduce the perils of the <windows.h> macros). This would change the library fundamentally so that it is no longer a header-only solution -- and this is not desirable.

Third-party implementations of std::filesystem should exist, which can be independently used.

Tested Compilers

This library has been tested against the following compilers / systems

CompilerOperating System
gcc-4.9Ubuntu 18.04
gcc-5.0Ubuntu 18.04
gcc-6Ubuntu 18.04
gcc-7Ubuntu 18.04
gcc-8Ubuntu 18.04
gcc-9Ubuntu 18.04
clang-3.5ubuntu 18.04
clang-3.6ubuntu 18.04
clang-3.7ubuntu 18.04
clang-3.8ubuntu 18.04
clang-3.9ubuntu 18.04
clang-4.0ubuntu 18.04
clang-5.0ubuntu 18.04
clang-6.0ubuntu 18.04
clang-7ubuntu 18.04
clang-8ubuntu 18.04
clang-9ubuntu 18.04
xcode-11.0macOS 10 (latest)
xcode-11.3macOS 10 (latest)
MSVC-2015 (14.0)Windows Server (latest)
MSVC-2017 (14.16)Windows Server (latest)
MSVC-2019 (14.24)Windows Server (latest)
clang-cl-9Windows Server (latest)
clang-9Windows Server (latest)
gcc-8.1Windows Server (latest)

<a name="license"></a>License

<img align="right" src="http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png">

Backport is licensed under the MIT License:

Copyright © 2020 Matthew Rodusek

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.