A standard conforming C++20 implementation of std::optional.

Overview

swl::optional

A standard conforming C++20 implementation of std::optional.

C++20 came with new features that makes the implementation of std::optional (and other types based on unions) a lot simpler to write, faster to compile, and more debugger-friendly (ever crawled through all the std::optional base classes in your IDE debugger?).
So if you're using optionala lot in C++20, switching to this implementation is free cookies.

Testing

The tests were adapted from TartanLlama's optional with some bits from the LLVM repo. Kudos to them.
To build all the tests, compile ./tests/test_main.cpp including the root of the repository in the search path, e.g. :
g++ -std=c++20 ./tests/test_main.cpp -I .

Tested compilers

  • GCC 11+
  • GCC 10+ (the early 10.X versions have a bug in std::construct_at, which prevent to use it in a constexpr context, hence the tests might not compile)
  • Clang will not fully work as its implementation of C++20 is still incomplete (Clang 12+ will work for trivially destructible type)
You might also like...
CloudABI's standard C library

NOTE: This project is unmaintained CloudABI is no longer being maintained. It was an awesome experiment, but it never got enough traction to be sustai

libcu++: The C++ Standard Library for Your Entire System

libcu++, the NVIDIA C++ Standard Library, is the C++ Standard Library for your entire system. It provides a heterogeneous implementation of the C++ Standard Library that can be used in and between CPU and GPU code.

EASTL stands for Electronic Arts Standard C++ Template Library

EASTL stands for Electronic Arts Standard Template Library. It is an extensive and robust implementation that has an emphasis on high performance.

An open source standard C library that includes useful functions && (Reimplementation of libc functions + own functions).
An open source standard C library that includes useful functions && (Reimplementation of libc functions + own functions).

📖 LIBFT-42 : Artistic view of LIBC: 🎭 HOW DOES IT FEEL HAVING YOUR OWN LIB: SUBJECT : ENGLISH PDF â„šī¸ What is LIBFT : This project aims to code a C l

Your standard library for metaprogramming

Boost.Hana Your standard library for metaprogramming Overview #include boost/hana.hpp #include cassert #include string namespace hana = boost::h

Reimplementation of some of the Standard C Library functions.
Reimplementation of some of the Standard C Library functions.

42-libft Reimplementation of some of the Standard C Library functions. This repository contains some of the standard library C functions. List of avai

Libft is an individual project at 42 that requires us to re-create some standard C library functions including some additional ones that can be used later to build a library of useful functions for the rest of the program.

🔖 Index What is Libft? List of Functions Technologies ✨ What is Libft? Libft is an individual project at 42 that requires us to re-create some standa

STXXL: Standard Template Library for Extra Large Data Sets

STXXL is an implementation of the C++ standard template library STL for external memory (out-of-core) computations

Thrust is a C++ parallel programming library which resembles the C++ Standard Library.

Thrust: Code at the speed of light Thrust is a C++ parallel programming library which resembles the C++ Standard Library. Thrust's high-level interfac

Owner
groundswell everything
null
C++11/14/17 std::optional with functional-style extensions and reference support

optional Single header implementation of std::optional with functional-style extensions and support for references. Clang + GCC: MSVC: std::optional i

Sy Brand 699 Dec 23, 2022
Monadic interface for std::optional

optional Simple monadic interface for std::optional Installation Just copy and include optional.h header in your project Usage All operations are in b

null 8 Apr 15, 2022
Named Optional Arguments in C++17

Optional Argument in C++ News Mon 02 Dec 2019 [0.0.2 tag] Cancel any possible implicit conversion by making constructors explicit. Thu 21 Nov 2019 [0.

pixor 8 Dec 2, 2019
MSVC's implementation of the C++ Standard Library.

Microsoft's C++ Standard Library This is the official repository for Microsoft's implementation of the C++ Standard Library (also known as the STL), w

Microsoft 8.4k Dec 27, 2022
C++11/14/17 std::expected with functional-style extensions

expected Single header implementation of std::expected with functional-style extensions. Clang + GCC: MSVC: Available on Vcpkg and Conan. std::expecte

Sy Brand 946 Jan 1, 2023
A collection of std-like single-header C++ libraries

itlib: iboB's Template Libraries A collection of small single-header C++ libraries similar to or extending the C++ standard library. See below for a l

Borislav Stanimirov 98 Dec 29, 2022
Range library for C++14/17/20, basis for C++20's std::ranges

range-v3 Range library for C++14/17/20. This code was the basis of a formal proposal to add range support to the C++ standard library. That proposal e

Eric Niebler 3.6k Dec 29, 2022
Allows a programmer to print table-like outputs over std::ostream.

tableprinter Allows a programmer to print table-like outputs over std::ostream. It is a header only library. No other dependency than STL. Provides re

null 24 Jul 7, 2022
Improved and configurable drop-in replacement to std::function that supports move only types, multiple overloads and more

fu2::function an improved drop-in replacement to std::function Provides improved implementations of std::function: copyable fu2::function move-only fu

Denis Blank 429 Dec 12, 2022
Bionic BSD-3-ClauseBionic - Google's standard library, developed for Android. BSD-3-Clause

bionic bionic is Android's C library, math library, and dynamic linker. Using bionic as an app developer See the user documentation. Working on bionic

Android Open Source Project 564 Dec 31, 2022