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 66") {
int i = 42;
tl::optional<int&> a = i;
tl::optional<const int&> b = a;
REQUIRE(&b.value() == &i);
b = a;
REQUIRE(&b.value() == &i);
}
I'd like this to compile, but it doesn't.
tl-optional/tests/issues.cpp:50:30: error: no viable conversion from 'optional<int &>' to 'optional<const int &>'
tl::optional<const int&> b = a;
^ ~
However, I understand that making this work is difficult pre-C++20 because of the lack of "explicit(bool)," so this might be deliberately "out of scope" for tl::optional. If so, feel free to close as WONTFIX.
Oddly, the assignment operator b = a;does compile and seems to work correctly, even though the converting constructor is missing. Even if you don't add the converting ctor (because difficult), you might consider removing the converting assignment operator (for self-consistency).
The text was updated successfully, but these errors were encountered:
I'd like this to compile, but it doesn't.
However, I understand that making this work is difficult pre-C++20 because of the lack of "
explicit(bool)
," so this might be deliberately "out of scope" fortl::optional
. If so, feel free to close as WONTFIX.Oddly, the assignment operator
b = a;
does compile and seems to work correctly, even though the converting constructor is missing. Even if you don't add the converting ctor (because difficult), you might consider removing the converting assignment operator (for self-consistency).The text was updated successfully, but these errors were encountered: