diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e7bcd7..fe45fae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/extensions.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/assignment.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/emplace.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tests/issues.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/bases.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/observers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/constructors.cpp) diff --git a/tests/issues.cpp b/tests/issues.cpp new file mode 100644 index 0000000..2dc4201 --- /dev/null +++ b/tests/issues.cpp @@ -0,0 +1,26 @@ +#include "catch.hpp" +#include "expected.hpp" + +#include + +using std::string; + +tl::expected getInt3(int val) +{ + return val; +} + +tl::expected getInt2(int val) +{ + return val; +} + +tl::expected getInt1() +{ + return getInt2(5).and_then(getInt3); +} + + +TEST_CASE("Issue 1", "[issues.1]") { + getInt1(); +} diff --git a/tl/expected.hpp b/tl/expected.hpp index 83f2123..7e69795 100644 --- a/tl/expected.hpp +++ b/tl/expected.hpp @@ -375,7 +375,7 @@ template struct expected_storage_base { // T is trivial, E is not. template struct expected_storage_base { constexpr expected_storage_base() : m_val(T{}), m_has_val(true) {} - constexpr expected_storage_base(no_init_t) : m_has_val(false) {} + TL_EXPECTED_MSVC2015_CONSTEXPR expected_storage_base(no_init_t) : m_has_val(false) {} template ::value> * = @@ -1477,14 +1477,14 @@ public: class U = T, detail::enable_if_t::value> * = nullptr, detail::expected_enable_forward_value * = nullptr> - explicit constexpr expected(U &&v) : expected(in_place, std::forward(v)) {} + explicit TL_EXPECTED_MSVC2015_CONSTEXPR expected(U &&v) : expected(in_place, std::forward(v)) {} /// \exclude template < class U = T, detail::enable_if_t::value> * = nullptr, detail::expected_enable_forward_value * = nullptr> - constexpr expected(U &&v) : expected(in_place, std::forward(v)) {} + TL_EXPECTED_MSVC2015_CONSTEXPR expected(U &&v) : expected(in_place, std::forward(v)) {} template < class U = T,