diff --git a/optional.hpp b/optional.hpp index a8082a7..fc33a67 100644 --- a/optional.hpp +++ b/optional.hpp @@ -14,6 +14,9 @@ #ifndef TL_OPTIONAL_HPP #define TL_OPTIONAL_HPP +#define TL_OPTIONAL_VERSION_MAJOR 0 +#define TL_OPTIONAL_VERSION_MINOR 2 + #include #include #include @@ -42,7 +45,7 @@ #if (__cplusplus == 201103L || defined(TL_OPTIONAL_MSVC2015) || \ defined(TL_OPTIONAL_GCC49)) && \ - !defined(TL_OPTIONAL_GCC50) + !defined(TL_OPTIONAL_GCC54) /// \exclude #define TL_OPTIONAL_11_CONSTEXPR #else @@ -577,7 +580,7 @@ public: // The different versions for C++14 and 11 are needed because deduced return // types are not SFINAE-safe. C.f. // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0826r0.html -#ifdef TL_OPTIONAL_CXX14 +#if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) /// \group and_then /// Carries out some operation which returns an optional on the stored object /// if there is one. \requires `std::invoke(std::forward(f), value())` @@ -689,7 +692,7 @@ public: #endif #endif -#ifdef TL_OPTIONAL_CXX14 +#if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) /// \brief Carries out some operation on the stored object if there is one. /// \returns Let `U` be the result of `std::invoke(std::forward(f), /// value())`. Returns a `std::optional`. The return value is empty if diff --git a/tests/extensions.cpp b/tests/extensions.cpp index d545fab..4fc01f7 100644 --- a/tests/extensions.cpp +++ b/tests/extensions.cpp @@ -122,8 +122,7 @@ TEST_CASE("Monadic operations", "[monadic]") { } SECTION("map constexpr") { -#if !defined(_MSC_VER) && !defined(TL_OPTIONAL_GCC49) && \ - !defined(TL_OPTIONAL_GCC54) +#if !defined(_MSC_VER) && !defined(TL_OPTIONAL_GCC49) // test each overload in turn constexpr tl::optional o16 = 42; constexpr auto o16r = o16.map(get_int); @@ -233,8 +232,8 @@ TEST_CASE("Monadic operations", "[monadic]") { } SECTION("constexpr and_then") { -#if !defined(_MSC_VER) && !defined(TL_OPTIONAL_GCC49) && \ - !defined(TL_OPTIONAL_GCC54) +#if !defined(_MSC_VER) && !defined(TL_OPTIONAL_GCC49) + constexpr tl::optional o10 = 42; constexpr auto o10r = o10.and_then(get_opt_int); REQUIRE(*o10r == 42); @@ -318,7 +317,7 @@ TEST_CASE("Monadic operations", "[monadic]") { void non_const() {} }; -#ifdef TL_OPTIONAL_CXX14 +#if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && !defined(TL_EXPECTED_GCC54) SECTION("Issue #1") { tl::optional f = foo{}; auto l = [](auto &&x) { x.non_const(); };