forked from OSchip/llvm-project
Update status for std::optional LWG issues and fix an optional SFINAE bug
llvm-svn: 284323
This commit is contained in:
parent
50253ed1c6
commit
015fcffd57
|
@ -487,7 +487,11 @@ public:
|
|||
operator->() const
|
||||
{
|
||||
_LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value");
|
||||
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
|
||||
return _VSTD::addressof(this->__val_);
|
||||
#else
|
||||
return __operator_arrow(__has_operator_addressof<value_type>{});
|
||||
#endif
|
||||
}
|
||||
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
|
|
|
@ -681,12 +681,14 @@ public:
|
|||
// LWG2756
|
||||
template <class _Up = value_type,
|
||||
class = enable_if_t
|
||||
<
|
||||
!is_same_v<_Up, optional> &&
|
||||
!(is_same_v<_Up, value_type> && is_scalar_v<value_type>) &&
|
||||
is_constructible_v<value_type, _Up> &&
|
||||
is_assignable_v<value_type&, _Up>
|
||||
>
|
||||
<__lazy_and<
|
||||
integral_constant<bool,
|
||||
!is_same_v<decay_t<_Up>, optional> &&
|
||||
!(is_same_v<_Up, value_type> && is_scalar_v<value_type>)
|
||||
>,
|
||||
is_constructible<value_type, _Up>,
|
||||
is_assignable<value_type&, _Up>
|
||||
>::value>
|
||||
>
|
||||
_LIBCPP_INLINE_VISIBILITY
|
||||
optional&
|
||||
|
|
|
@ -51,6 +51,9 @@ int main()
|
|||
{
|
||||
constexpr optional<Z> opt(Z{});
|
||||
assert(opt->test() == 1);
|
||||
#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
|
||||
static_assert(opt->test() == 1, "");
|
||||
#endif
|
||||
}
|
||||
#ifdef _LIBCPP_DEBUG
|
||||
{
|
||||
|
|
|
@ -48,6 +48,16 @@ struct MismatchType {
|
|||
MismatchType& operator=(char*) = delete;
|
||||
};
|
||||
|
||||
struct FromOptionalType {
|
||||
using Opt = std::optional<FromOptionalType>;
|
||||
FromOptionalType() = default;
|
||||
FromOptionalType(FromOptionalType const&) = delete;
|
||||
template <class Dummy = void>
|
||||
constexpr FromOptionalType(Opt&) { Dummy::BARK; }
|
||||
template <class Dummy = void>
|
||||
constexpr FromOptionalType& operator=(Opt&) { Dummy::BARK; return *this; }
|
||||
};
|
||||
|
||||
void test_sfinae() {
|
||||
using I = TestTypes::TestType;
|
||||
using E = ExplicitTestTypes::TestType;
|
||||
|
@ -68,6 +78,8 @@ void test_sfinae() {
|
|||
assert_assignable<MismatchType, int>();
|
||||
assert_assignable<MismatchType, int*, false>();
|
||||
assert_assignable<MismatchType, char*, false>();
|
||||
// Type constructible from optional
|
||||
assert_assignable<FromOptionalType, std::optional<FromOptionalType>&, false>();
|
||||
}
|
||||
|
||||
void test_with_test_type()
|
||||
|
|
|
@ -109,19 +109,19 @@
|
|||
<tr><td><a href="http://wg21.link/LWG2736">2736</a></td><td>nullopt_t insufficiently constrained</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2738">2738</a></td><td>is_constructible with void types</td><td>Issaquah</td><td>We already do this</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2739">2739</a></td><td>Issue with time_point non-member subtraction with an unsigned duration</td><td>Issaquah</td><td>Patch Ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2740">2740</a></td><td>constexpr optional<T>::operator-></td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2740">2740</a></td><td>constexpr optional<T>::operator-></td><td>Issaquah</td><td>We already do this</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2742">2742</a></td><td>Inconsistent string interface taking string_view</td><td>Issaquah</td><td>Patch Ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2744">2744</a></td><td>any's in_place constructors</td><td>Issaquah</td><td>Implemented in trunk</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2745">2745</a></td><td>[fund.ts.v2] Implementability of LWG 2451</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2747">2747</a></td><td>Possibly redundant std::move in [alg.foreach]</td><td>Issaquah</td><td>Patch ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2748">2748</a></td><td>swappable traits for optionals</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2748">2748</a></td><td>swappable traits for optionals</td><td>Issaquah</td><td>We already do this</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2749">2749</a></td><td>swappable traits for variants</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2750">2750</a></td><td>[fund.ts.v2] LWG 2451 conversion constructor constraint</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2752">2752</a></td><td>"Throws:" clauses of async and packaged_task are unimplementable</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2753">2753</a></td><td>Optional's constructors and assignments need constraints</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2753">2753</a></td><td>Optional's constructors and assignments need constraints</td><td>Issaquah</td><td>We already do this</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2754">2754</a></td><td>The in_place constructors and emplace functions added by P0032R3 don't require CopyConstructible</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2755">2755</a></td><td>§[string.view.io] uses non-existent basic_string_view::to_string function</td><td>Issaquah</td><td>We already do this</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2756">2756</a></td><td>C++ WP optional<T> should 'forward' T's implicit conversions</td><td>Issaquah</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2756">2756</a></td><td>C++ WP optional<T> should 'forward' T's implicit conversions</td><td>Issaquah</td><td>Implemented in trunk</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2758">2758</a></td><td>std::string{}.assign("ABCDE", 0, 1) is ambiguous</td><td>We already do this</td><td></td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2759">2759</a></td><td>gcd / lcm and bool for the WP</td><td>Issaquah</td><td>Patch ready</td></tr>
|
||||
<tr><td><a href="http://wg21.link/LWG2760">2760</a></td><td>non-const basic_string::data should not invalidate iterators</td><td>Issaquah</td><td>Nothing to do</td></tr>
|
||||
|
@ -187,19 +187,19 @@
|
|||
<li>2736 - </li>
|
||||
<li>2738 - We already do this; I added tests for cv-void</li>
|
||||
<li>2739 - Patch and tests ready</li>
|
||||
<li>2740 - <i>std::optional</i></li>
|
||||
<li>2740 - <i>std::optional</i>: The resolution LGTM. </li>
|
||||
<li>2742 - Patch and tests ready</li>
|
||||
<li>2744 - <i>std::any</i>: We already do this. We also check for a decayed in_place_type_t. </li>
|
||||
<li>2745 - <i>std::optional</i> for LFTS -- should be considered for C++17</li>
|
||||
<li>2747 - Patch ready, but I can't think of any way to test it.</li>
|
||||
<li>2748 - <i>std::optional</i></li>
|
||||
<li>2748 - <i>std::optional</i>: LGTM. </li>
|
||||
<li>2749 - <i>std::variant</i></li>
|
||||
<li>2750 - <i>std::optional</i> for LFTS -- should be considered for C++17</li>
|
||||
<li>2752 - </li>
|
||||
<li>2753 - <i>std::optional</i></li>
|
||||
<li>2753 - <i>std::optional</i>: LGTM. </li>
|
||||
<li>2754 - </li>
|
||||
<li>2755 - Both string and string_view call a common routine for output; so no code changes needed.</li>
|
||||
<li>2756 - <i>std::optional</i></li>
|
||||
<li>2756 - <i>std::optional</i>: Very large change. It is fully implemented and tested. </li>
|
||||
<li>2758 - We already do this. </li>
|
||||
<li>2759 - Patch and tests ready</li>
|
||||
<li>2760 - This is just wording cleanup; no code or test changes needed.</li>
|
||||
|
|
Loading…
Reference in New Issue