Constexpr fixes

This commit is contained in:
Simon Brand
2017-12-05 20:45:35 +00:00
parent 45ae6b4001
commit d5bc89aa18

View File

@@ -72,6 +72,12 @@
#define TL_EXPECTED_CXX14 #define TL_EXPECTED_CXX14
#endif #endif
#ifdef TL_EXPECTED_GCC49
#define TL_EXPECTED_GCC49_CONSTEXPR
#else
#define TL_EXPECTED_GCC49_CONSTEXPR constexpr
#endif
#if (__cplusplus == 201103L || defined(TL_EXPECTED_MSVC2015) || \ #if (__cplusplus == 201103L || defined(TL_EXPECTED_MSVC2015) || \
defined(TL_EXPECTED_GCC49)) && \ defined(TL_EXPECTED_GCC49)) && \
!defined(TL_EXPECTED_GCC54) !defined(TL_EXPECTED_GCC54)
@@ -1582,7 +1588,7 @@ public:
/// \returns the contained value if there is one, otherwise throws [bad_expected_access] /// \returns the contained value if there is one, otherwise throws [bad_expected_access]
/// \group value /// \group value
constexpr const T &value() const & { TL_EXPECTED_GCC49_CONSTEXPR const T &value() const & {
if (!has_value()) if (!has_value())
throw bad_expected_access<E>(err().value()); throw bad_expected_access<E>(err().value());
return val(); return val();
@@ -1594,7 +1600,7 @@ public:
return val(); return val();
} }
/// \group value /// \group value
constexpr const T &&value() const && { TL_EXPECTED_GCC49_CONSTEXPR const T &&value() const && {
if (!has_value()) if (!has_value())
throw bad_expected_access<E>(err().value()); throw bad_expected_access<E>(err().value());
return std::move(val()); return std::move(val());