You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TEST_CASE("issue 67") {
int i = 42;
int j = 43;
tl::optional<std::reference_wrapper<int>> a = std::ref(i);
REQUIRE(&a.value().get() == &i);
a = std::ref(j);
REQUIRE(&a.value().get() == &j);
tl::optional<int&> b = std::ref(i);
REQUIRE(&b.value() == &i);
b = std::ref(j);
REQUIRE(&b.value() == &j);
}
Instead, it currently fails to compile:
tl-optional/include/tl/optional.hpp:1942:41: error: cannot initialize a member subobject of type 'int *' with an rvalue of type 'std::reference_wrapper<int> *'
constexpr optional(U &&u) noexcept : m_value(std::addressof(u)) {
^ ~~~~~~~~~~~~~~~~~
tl-optional/tests/issues.cpp:55:28: note: in instantiation of function template specialization 'tl::optional<int &>::optional<std::reference_wrapper<int>, nullptr>' requested here
tl::optional<int&> b = std::ref(i);
^
Furthermore, I'd like the following to compile too:
tl::optional<int&> c = a;
REQUIRE(&c.value() == &j);
c = tl::optional<std::reference_wrapper<int>>(std::ref(i));
REQUIRE(&c.value() == &i);
I would expect this test case to pass:
Instead, it currently fails to compile:
Furthermore, I'd like the following to compile too:
But that requires solving issue #66 first.
The text was updated successfully, but these errors were encountered: