Merge branch 'master' of github.com:TartanLlama/monadic-optional-new

This commit is contained in:
Simon Brand
2017-11-01 15:44:08 +00:00
2 changed files with 10 additions and 8 deletions

View File

@ -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 <exception>
#include <functional>
#include <new>
@ -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>(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>(f),
/// value())`. Returns a `std::optional<U>`. The return value is empty if

View File

@ -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<int> 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<int> 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<foo> f = foo{};
auto l = [](auto &&x) { x.non_const(); };