@@ -696,7 +696,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Up = _Tp,
_Requires<__not_self<_Up>, __not_tag<_Up>,
is_constructible<_Tp, _Up&&>,
+#if __cpp_aggregate_paren_init
+ __or_<is_aggregate<_Tp>,
+ is_convertible<_Up&&, _Tp>>> = true>
+#else
is_convertible<_Up&&, _Tp>> = true>
+#endif
constexpr
optional(_Up&& __t)
: _Base(std::in_place, std::forward<_Up>(__t)) { }
@@ -704,7 +709,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Up = _Tp,
_Requires<__not_self<_Up>, __not_tag<_Up>,
is_constructible<_Tp, _Up&&>,
+#if __cpp_aggregate_paren_init
+ __not_<__or_<is_aggregate<_Tp>,
+ is_convertible<_Up&&, _Tp>>>> = false>
+#else
__not_<is_convertible<_Up&&, _Tp>>> = false>
+#endif
explicit constexpr
optional(_Up&& __t)
: _Base(std::in_place, std::forward<_Up>(__t)) { }
@@ -467,7 +467,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static constexpr bool __is_implicitly_constructible()
{
return __and_<is_constructible<_Types, _UTypes>...,
+#if __cpp_aggregate_paren_init
+ __or_<is_aggregate<_Types>,
+ is_convertible<_UTypes, _Types>>...
+#else
is_convertible<_UTypes, _Types>...
+#endif
>::value;
}
@@ -478,8 +483,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static constexpr bool __is_explicitly_constructible()
{
return __and_<is_constructible<_Types, _UTypes>...,
- __not_<__and_<is_convertible<_UTypes, _Types>...>>
- >::value;
+ __not_<__and_<
+#if __cpp_aggregate_paren_init
+ __or_<is_aggregate<_Types>,
+ is_convertible<_UTypes, _Types>>...>
+#else
+ is_convertible<_UTypes, _Types>...>
+#endif
+ >>::value;
}
static constexpr bool __is_implicitly_default_constructible()
new file mode 100644
@@ -0,0 +1,26 @@
+// Copyright (C) 2019-2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "--std=gnu++17" }
+// { dg-do compile { target c++17 } }
+
+#include <optional>
+
+struct c { int i; };
+
+std::optional<c> x({0});
+
new file mode 100644
@@ -0,0 +1,25 @@
+// Copyright (C) 2019-2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <tuple>
+
+struct c { int i; };
+
+std::tuple<c> x({0});
+