From dc02563d7b36ba2bc007be69885e6020f734d14d Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Fri, 9 Nov 2018 15:34:16 +0000 Subject: [PATCH 1/7] Update version --- tl/optional.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tl/optional.hpp b/tl/optional.hpp index c63d820..1c6480f 100644 --- a/tl/optional.hpp +++ b/tl/optional.hpp @@ -16,7 +16,7 @@ #define TL_OPTIONAL_HPP #define TL_OPTIONAL_VERSION_MAJOR 0 -#define TL_OPTIONAL_VERSION_MINOR 2 +#define TL_OPTIONAL_VERSION_MINOR 5 #include #include From 99b2a15863e44782ff1295c60b979f5e1ceee916 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 22 Nov 2018 22:49:33 +0300 Subject: [PATCH 2/7] Misaligned template specifiers Tried to compile with CLion + CLang + WSL, got error pointing to this place. Looks like a copy-paste error ) --- tl/optional.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tl/optional.hpp b/tl/optional.hpp index 1c6480f..88ce30e 100644 --- a/tl/optional.hpp +++ b/tl/optional.hpp @@ -66,8 +66,8 @@ namespace tl { namespace detail { template struct is_trivially_copy_constructible : std::is_trivially_copy_constructible{}; - template #ifdef _GLIBCXX_VECTOR + template struct is_trivially_copy_constructible> : std::is_trivially_copy_constructible{}; #endif From c194f73a0726bdea33d1ec3708ee1d2466eeaabc Mon Sep 17 00:00:00 2001 From: johvik Date: Wed, 23 Jan 2019 08:38:31 +0100 Subject: [PATCH 3/7] Return value() in noexcept emplace --- tl/optional.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tl/optional.hpp b/tl/optional.hpp index 88ce30e..7350f8a 100644 --- a/tl/optional.hpp +++ b/tl/optional.hpp @@ -2252,6 +2252,7 @@ public: *this = nullopt; this->construct(std::forward(args)...); + return value(); } /// Swaps this optional with the other. From 5d3d6c399ad509bc758b0aee48d9307a814148fe Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Mon, 11 Feb 2019 11:38:24 +0000 Subject: [PATCH 4/7] Add email address Fixes #18 --- tl/optional.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tl/optional.hpp b/tl/optional.hpp index 7350f8a..395c58a 100644 --- a/tl/optional.hpp +++ b/tl/optional.hpp @@ -1,7 +1,7 @@ /// // optional - An implementation of std::optional with extensions -// Written in 2017 by Simon Brand (@TartanLlama) +// Written in 2017 by Simon Brand (tartanllama@gmail.com, @TartanLlama) // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to the From 1de2f2a49cc0d20860f675d426221872db40c51f Mon Sep 17 00:00:00 2001 From: The Phantom Derpstorm Date: Wed, 13 Feb 2019 09:00:07 -0500 Subject: [PATCH 5/7] [ constructors ] prevent empty optional access optional types being taken in were forwarding their values without checking, resulting in segfaults on optional -> optional conversions. This fixes those problems in the constructors. --- tl/optional.hpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tl/optional.hpp b/tl/optional.hpp index 395c58a..8212923 100644 --- a/tl/optional.hpp +++ b/tl/optional.hpp @@ -1190,7 +1190,9 @@ public: class U, detail::enable_from_other * = nullptr, detail::enable_if_t::value> * = nullptr> optional(const optional &rhs) { - this->construct(*rhs); + if (rhs.has_value()) { + this->construct(*rhs); + } } /// \exclude @@ -1198,7 +1200,9 @@ public: detail::enable_if_t::value> * = nullptr> explicit optional(const optional &rhs) { - this->construct(*rhs); + if (rhs.has_value()) { + this->construct(*rhs); + } } /// Converting move constructor. @@ -1207,7 +1211,9 @@ public: class U, detail::enable_from_other * = nullptr, detail::enable_if_t::value> * = nullptr> optional(optional &&rhs) { - this->construct(std::move(*rhs)); + if (rhs.has_value()) { + this->construct(std::move(*rhs)); + } } /// \exclude @@ -1215,7 +1221,9 @@ public: class U, detail::enable_from_other * = nullptr, detail::enable_if_t::value> * = nullptr> explicit optional(optional &&rhs) { - this->construct(std::move(*rhs)); + if (rhs.has_value()) { + this->construct(std::move(*rhs)); + } } /// Destroys the stored value if there is one. From 4304148904fede8d68915862189e59a361cf4bcf Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Tue, 19 Feb 2019 09:51:23 +0000 Subject: [PATCH 6/7] Turn docs off by default Fixes #20 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63720f6..c4aae8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.0) project(optional) option(OPTIONAL_ENABLE_TESTS "Enable tests." ON) -option(OPTIONAL_ENABLE_DOCS "Enable documentation." ON) +option(OPTIONAL_ENABLE_DOCS "Enable documentation." OFF) add_library(optional INTERFACE) target_sources(optional INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tl/optional.hpp) From 7de669d9c7e2d934c16fa1b329ac8b0b5c104dc5 Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Mon, 29 Apr 2019 14:58:31 +0100 Subject: [PATCH 7/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90d3000..87418ef 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ tl::optional get_cute_cat (const image& img) { } ``` -Full documentation available at [optional.tartanllama.xyz](https://optional.tartanllama.xyz) +Full documentation available at [tl.tartanllama.xyz](https://tl.tartanllama.xyz) The interface is the same as `std::optional`, but the following member functions are also defined. Explicit types are for clarity.