diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2019-10-11 16:53:52 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-10-11 16:53:52 +0100 |
commit | cfc219ae689fd94bbe1bb12686bb04fa09b93046 (patch) | |
tree | ff762f43759af77cdeff475bc1f39c79ffb92540 /libstdc++-v3 | |
parent | 02f6fdff65671ccfaf2f79092ccdfccdef1bcebf (diff) | |
download | gcc-cfc219ae689fd94bbe1bb12686bb04fa09b93046.zip gcc-cfc219ae689fd94bbe1bb12686bb04fa09b93046.tar.gz gcc-cfc219ae689fd94bbe1bb12686bb04fa09b93046.tar.bz2 |
Implement <concepts> header for C++20
There are currently no tests for [concepts.compare], but they will be
added ASAP.
* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/precompiled/stdc++.h: Include <concepts>.
* include/std/concepts: New header for C++20.
* include/std/version (__cpp_lib_concepts): Define.
* scripts/create_testsuite_files: Look for test files in new std
directory.
* testsuite/libstdc++-dg/conformance.exp: Likewise.
* testsuite/std/concepts/concepts.callable/invocable.cc: New test.
* testsuite/std/concepts/concepts.callable/regular_invocable.cc: New
test.
* testsuite/std/concepts/concepts.callable/relation.cc: New test.
* testsuite/std/concepts/concepts.callable/strictweakorder.cc: New
test.
* testsuite/std/concepts/concepts.lang/concept.arithmetic/
floating_point.cc: New test.
* testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.arithmetic/
signed_integral.cc: New test.
* testsuite/std/concepts/concepts.lang/concept.arithmetic/
unsigned_integral.cc: New test.
* testsuite/std/concepts/concepts.lang/concept.assignable/1.cc: New
test.
* testsuite/std/concepts/concepts.lang/concept.common/1.cc: New test.
* testsuite/std/concepts/concepts.lang/concept.commonref/1.cc: New
test.
* testsuite/std/concepts/concepts.lang/concept.constructible/1.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.convertible/1.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.copyconstructible/1.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.defaultconstructible/
1.cc: New test.
* testsuite/std/concepts/concepts.lang/concept.derived/1.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.destructible/1.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.moveconstructible/1.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.same/1.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc:
New test.
* testsuite/std/concepts/concepts.lang/concept.swappable/
swappable_with.cc: New test.
* testsuite/std/concepts/concepts.object/copyable.cc: New test.
* testsuite/std/concepts/concepts.object/movable.cc: New test.
* testsuite/std/concepts/concepts.object/regular.cc: New test.
* testsuite/std/concepts/concepts.object/semiregular.cc: New test.
From-SVN: r276892
Diffstat (limited to 'libstdc++-v3')
34 files changed, 2139 insertions, 8 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4b1b010..8119455 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,59 @@ 2019-10-11 Jonathan Wakely <jwakely@redhat.com> + * include/Makefile.am: Add new header. + * include/Makefile.in: Regenerate. + * include/precompiled/stdc++.h: Include <concepts>. + * include/std/concepts: New header for C++20. + * include/std/version (__cpp_lib_concepts): Define. + * scripts/create_testsuite_files: Look for test files in new std + directory. + * testsuite/libstdc++-dg/conformance.exp: Likewise. + * testsuite/std/concepts/concepts.callable/invocable.cc: New test. + * testsuite/std/concepts/concepts.callable/regular_invocable.cc: New + test. + * testsuite/std/concepts/concepts.callable/relation.cc: New test. + * testsuite/std/concepts/concepts.callable/strictweakorder.cc: New + test. + * testsuite/std/concepts/concepts.lang/concept.arithmetic/ + floating_point.cc: New test. + * testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.arithmetic/ + signed_integral.cc: New test. + * testsuite/std/concepts/concepts.lang/concept.arithmetic/ + unsigned_integral.cc: New test. + * testsuite/std/concepts/concepts.lang/concept.assignable/1.cc: New + test. + * testsuite/std/concepts/concepts.lang/concept.common/1.cc: New test. + * testsuite/std/concepts/concepts.lang/concept.commonref/1.cc: New + test. + * testsuite/std/concepts/concepts.lang/concept.constructible/1.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.convertible/1.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.copyconstructible/1.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.defaultconstructible/ + 1.cc: New test. + * testsuite/std/concepts/concepts.lang/concept.derived/1.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.destructible/1.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.moveconstructible/1.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.same/1.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc: + New test. + * testsuite/std/concepts/concepts.lang/concept.swappable/ + swappable_with.cc: New test. + * testsuite/std/concepts/concepts.object/copyable.cc: New test. + * testsuite/std/concepts/concepts.object/movable.cc: New test. + * testsuite/std/concepts/concepts.object/regular.cc: New test. + * testsuite/std/concepts/concepts.object/semiregular.cc: New test. + * include/std/type_traits (is_same): Replace partial specialization by using __is_same_as built-in in primary template. (is_same_v): Use __is_same_as built-in instead of instantiating the diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 3e9540c..35ee3cf 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -36,6 +36,7 @@ std_headers = \ ${std_srcdir}/chrono \ ${std_srcdir}/codecvt \ ${std_srcdir}/complex \ + ${std_srcdir}/concepts \ ${std_srcdir}/condition_variable \ ${std_srcdir}/deque \ ${std_srcdir}/execution \ @@ -1379,8 +1380,8 @@ endif # This is a subset of the full install-headers rule. We only need <ciso646>, # <cstddef>, <cfloat>, <limits>, <climits>, <version>, <cstdint>, <cstdlib>, # <new>, <typeinfo>, <exception>, <initializer_list>, <cstdalign>, <cstdarg>, -# <cstdbool>, <type_traits>, <bit>, <atomic>, and any files which they include -# (and which we provide). +# <concepts>, <cstdbool>, <type_traits>, <bit>, <atomic>, +# and any files which they include (and which we provide). # <new>, <typeinfo>, <exception>, and <initializer_list> are installed by # libsupc++, so only the others and the sub-includes are copied here. install-freestanding-headers: @@ -1393,7 +1394,7 @@ install-freestanding-headers: ${glibcxx_srcdir}/$(CPU_DEFINES_SRCDIR)/cpu_defines.h; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir} - for file in limits type_traits atomic bit version; do \ + for file in limits type_traits atomic bit concepts version; do \ $(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir} for file in ciso646 cstddef cfloat climits cstdint cstdlib \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 24e1363..5d04888 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -380,6 +380,7 @@ std_headers = \ ${std_srcdir}/chrono \ ${std_srcdir}/codecvt \ ${std_srcdir}/complex \ + ${std_srcdir}/concepts \ ${std_srcdir}/condition_variable \ ${std_srcdir}/deque \ ${std_srcdir}/execution \ @@ -1853,8 +1854,8 @@ ${pch3_output}: ${pch3_source} ${pch2_output} # This is a subset of the full install-headers rule. We only need <ciso646>, # <cstddef>, <cfloat>, <limits>, <climits>, <version>, <cstdint>, <cstdlib>, # <new>, <typeinfo>, <exception>, <initializer_list>, <cstdalign>, <cstdarg>, -# <cstdbool>, <type_traits>, <bit>, <atomic>, and any files which they include -# (and which we provide). +# <concepts>, <cstdbool>, <type_traits>, <bit>, <atomic>, +# and any files which they include (and which we provide). # <new>, <typeinfo>, <exception>, and <initializer_list> are installed by # libsupc++, so only the others and the sub-includes are copied here. install-freestanding-headers: @@ -1867,7 +1868,7 @@ install-freestanding-headers: ${glibcxx_srcdir}/$(CPU_DEFINES_SRCDIR)/cpu_defines.h; do \ $(INSTALL_DATA) $${file} $(DESTDIR)${host_installdir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${std_builddir} - for file in limits type_traits atomic bit version; do \ + for file in limits type_traits atomic bit concepts version; do \ $(INSTALL_DATA) ${std_builddir}/$${file} $(DESTDIR)${gxx_include_dir}/${std_builddir}; done $(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir} for file in ciso646 cstddef cfloat climits cstdint cstdlib \ diff --git a/libstdc++-v3/include/precompiled/stdc++.h b/libstdc++-v3/include/precompiled/stdc++.h index 4b668fd..fefd6e7 100644 --- a/libstdc++-v3/include/precompiled/stdc++.h +++ b/libstdc++-v3/include/precompiled/stdc++.h @@ -136,7 +136,7 @@ #if __cplusplus > 201703L #include <bit> // #include <compare> -// #include <concepts> +#include <concepts> #include <numbers> // #include <ranges> #include <span> diff --git a/libstdc++-v3/include/std/concepts b/libstdc++-v3/include/std/concepts new file mode 100644 index 0000000..6b1150a --- /dev/null +++ b/libstdc++-v3/include/std/concepts @@ -0,0 +1,351 @@ +// <concepts> -*- C++ -*- + +// Copyright (C) 2019 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. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received __a copy of the GNU General Public License and +// __a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +/** @file include/concepts + * This is __a Standard C++ Library header. + * @ingroup concepts + */ + +#ifndef _GLIBCXX_CONCEPTS +#define _GLIBCXX_CONCEPTS 1 + +#if __cplusplus > 201703L && __cpp_concepts + +#pragma GCC system_header + +/** + * @defgroup concepts Concepts + * @ingroup utilities + * + * Concepts for checking type requirements. + */ + +#include <type_traits> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_concepts 201806L + + // [concepts.lang], language-related concepts + + namespace __detail + { + template<typename _Tp, typename _Up> + concept __same_as = __is_same_as(_Tp, _Up); + } // namespace __detail + + /// [concept.same], concept same_as + template<typename _Tp, typename _Up> + concept same_as + = __detail::__same_as<_Tp, _Up> && __detail::__same_as<_Up, _Tp>; + + /// [concept.derived], concept derived_from + template<typename _Derived, typename _Base> + concept derived_from = __is_base_of(_Base, _Derived) + && is_convertible_v<const volatile _Derived*, const volatile _Base*>; + + /// [concept.convertible], concept convertible_to + template<typename _From, typename _To> + concept convertible_to = is_convertible_v<_From, _To> + && requires(add_rvalue_reference_t<_From> (&__f)()) { + static_cast<_To>(__f()); + }; + + /// [concept.commonref], concept common_reference_with + template<typename _Tp, typename _Up> + concept common_reference_with + = same_as<common_reference_t<_Tp, _Up>, common_reference_t<_Up, _Tp>> + && convertible_to<_Tp, common_reference_t<_Tp, _Up>> + && convertible_to<_Up, common_reference_t<_Tp, _Up>>; + + /// [concept.common], concept common_with + template<typename _Tp, typename _Up> + concept common_with + = same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> + && requires { + static_cast<common_type_t<_Tp, _Up>>(std::declval<_Tp>()); + static_cast<common_type_t<_Tp, _Up>>(std::declval<_Up>()); + } + && common_reference_with<add_lvalue_reference_t<const _Tp>, + add_lvalue_reference_t<const _Up>> + && common_reference_with<add_lvalue_reference_t<common_type_t<_Tp, _Up>>, + common_reference_t< + add_lvalue_reference_t<const _Tp>, + add_lvalue_reference_t<const _Up>>>; + + // [concepts.arithmetic], arithmetic concepts + + template<typename _Tp> + concept integral = is_integral_v<_Tp>; + + template<typename _Tp> + concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; + + template<typename _Tp> + concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; + + template<typename _Tp> + concept floating_point = is_floating_point_v<_Tp>; + + namespace __detail + { + template<typename _Tp> + using __cref = const remove_reference_t<_Tp>&; + } // namespace __detail + + /// [concept.assignable], concept assignable_from + template<typename _Lhs, typename _Rhs> + concept assignable_from + = is_lvalue_reference_v<_Lhs> + && common_reference_with<__detail::__cref<_Lhs>, __detail::__cref<_Rhs>> + && requires(_Lhs __lhs, _Rhs&& __rhs) { + { __lhs = static_cast<_Rhs&&>(__rhs) } -> same_as<_Lhs>; + }; + + /// [concept.destructible], concept destructible + template<typename _Tp> + concept destructible = is_nothrow_destructible_v<_Tp>; + + /// [concept.constructible], concept constructible_from + template<typename _Tp, typename... _Args> + concept constructible_from + = destructible<_Tp> && is_constructible_v<_Tp, _Args...>; + + /// [concept.defaultconstructible], concept default_constructible + template<typename _Tp> + concept default_constructible = constructible_from<_Tp>; + + /// [concept.moveconstructible], concept move_constructible + template<typename _Tp> + concept move_constructible + = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; + + /// [concept.copyconstructible], concept copy_constructible + template<typename _Tp> + concept copy_constructible + = move_constructible<_Tp> + && constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> + && constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> + && constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>; + + // [concept.swappable], concept swappable + + namespace ranges + { + namespace __cust_swap + { + template<typename _Tp> void swap(_Tp&, _Tp&) = delete; + + template<typename _Tp> + concept __class_or_enum + = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; + + template<typename _Tp, typename _Up> + concept __adl_swap + = (__class_or_enum<remove_cvref_t<_Tp>> + || __class_or_enum<remove_cvref_t<_Up>>) + && requires(_Tp&& __t, _Up&& __u) { + swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + }; + + struct _Swap + { + template<typename _Tp, typename _Up> + requires __adl_swap<_Tp, _Up> + constexpr void operator()(_Tp&& __t, _Up&& __u) const + noexcept(noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))) + { swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); } + + template<typename _Tp, typename _Up, size_t _Num> + requires requires(const _Swap& __swap, _Tp& __e1, _Up& __e2) { + __swap(__e1, __e2); + } + constexpr void + operator()(_Tp (&__e1)[_Num], _Up (&__e2)[_Num]) const + noexcept(noexcept(std::declval<const _Swap&>()(*__e1, *__e2))) + { + for (size_t __n = 0; __n < _Num; ++__n) + (*this)(__e1[__n], __e2[__n]); + } + + template<typename _Tp> + requires (!__adl_swap<_Tp&, _Tp&> + && move_constructible<_Tp> && assignable_from<_Tp&, _Tp>) + constexpr void + operator()(_Tp& __e1, _Tp& __e2) const + noexcept(is_nothrow_move_constructible_v<_Tp> + && is_nothrow_move_assignable_v<_Tp>) + { + _Tp __tmp = static_cast<_Tp&&>(__e1); + __e1 = static_cast<_Tp&&>(__e2); + __e2 = static_cast<_Tp&&>(__tmp); + } + }; + } // namespace __cust_swap + + inline namespace __cust + { + inline constexpr __cust_swap::_Swap swap{}; + } // inline namespace __cust + } // namespace ranges + + template<typename _Tp> + concept swappable + = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); }; + + template<typename _Tp, typename _Up> + concept swappable_with = common_reference_with<_Tp, _Up> + && requires(_Tp&& __t, _Up&& __u) { + ranges::swap(static_cast<_Tp&&>(__t), static_cast<_Tp&&>(__t)); + ranges::swap(static_cast<_Up&&>(__u), static_cast<_Up&&>(__u)); + ranges::swap(static_cast<_Tp&&>(__t), static_cast<_Up&&>(__u)); + ranges::swap(static_cast<_Up&&>(__u), static_cast<_Tp&&>(__t)); + }; + + // [concepts.object], Object concepts + + template<typename _Tp> + concept movable = is_object_v<_Tp> && move_constructible<_Tp> + && assignable_from<_Tp&, _Tp> && swappable<_Tp>; + + template<typename _Tp> + concept copyable = copy_constructible<_Tp> && movable<_Tp> + && assignable_from<_Tp&, const _Tp&>; + + template<typename _Tp> + concept semiregular = copyable<_Tp> && default_constructible<_Tp>; + + // [concepts.compare], comparison concepts + + /// [concept.boolean], concept boolean + template<typename _Bp> + concept boolean + = movable<remove_cvref_t<_Bp>> + && requires(__detail::__cref<_Bp> __b1, __detail::__cref<_Bp> __b2, + const bool __a) { + { __b1 } -> convertible_to<bool>; + { !__b1 } -> convertible_to<bool>; + { __b1 && __b2 } -> same_as<bool>; + { __b1 && __a } -> same_as<bool>; + { __a && __b2 } -> same_as<bool>; + { __b1 || __b2 } -> same_as<bool>; + { __b1 || __a } -> same_as<bool>; + { __a || __b2 } -> same_as<bool>; + { __b1 == __b2 } -> convertible_to<bool>; + { __b1 == __a } -> convertible_to<bool>; + { __a == __b2 } -> convertible_to<bool>; + { __b1 != __b2 } -> convertible_to<bool>; + { __b1 != __a } -> convertible_to<bool>; + { __a != __b2 } -> convertible_to<bool>; + }; + + // [concept.equalitycomparable], concept equality_comparable + + namespace __detail + { + template<typename _Tp, typename _Up> + concept __weakly_eq_cmp_with + = requires(__detail::__cref<_Tp> __t, __detail::__cref<_Up> __u) { + { __t == __u } -> boolean; + { __t != __u } -> boolean; + { __u == __t } -> boolean; + { __u != __t } -> boolean; + }; + } // namespace __detail + + template<typename _Tp> + concept equality_comparable = __detail::__weakly_eq_cmp_with<_Tp, _Tp>; + + template<typename _Tp, typename _Up> + concept equality_comparable_with + = equality_comparable<_Tp> && equality_comparable<_Up> + && common_reference_with<__detail::__cref<_Tp>, __detail::__cref<_Up>> + && equality_comparable<common_reference_t<__detail::__cref<_Tp>, + __detail::__cref<_Up>>> + && __detail::__weakly_eq_cmp_with<_Tp, _Up>; + + // [concept.totallyordered], concept totally_ordered + template<typename _Tp> + concept totally_ordered + = equality_comparable<_Tp> + && requires(__detail::__cref<_Tp> __a, __detail::__cref<_Tp> __b) { + { __a < __b } -> boolean; + { __a > __b } -> boolean; + { __a <= __b } -> boolean; + { __a >= __b } -> boolean; + }; + + template<typename _Tp, typename _Up> + concept totally_ordered_with + = totally_ordered<_Tp> && totally_ordered<_Up> + && common_reference_with<__detail::__cref<_Tp>, __detail::__cref<_Up>> + && totally_ordered<common_reference_t<__detail::__cref<_Tp>, + __detail::__cref<_Up>>> + && equality_comparable_with<_Tp, _Up> + && requires(__detail::__cref<_Tp> __t, __detail::__cref<_Up> __u) { + { __t < __u } -> boolean; + { __t > __u } -> boolean; + { __t <= __u } -> boolean; + { __t >= __u } -> boolean; + { __u < __t } -> boolean; + { __u > __t } -> boolean; + { __u <= __t } -> boolean; + { __u >= __t } -> boolean; + }; + + template<typename _Tp> + concept regular = semiregular<_Tp> && equality_comparable<_Tp>; + + // [concepts.callable], callable concepts + + // [concept.invocable], concept invocable + template<typename _Fn, typename... _Args> + concept invocable = is_invocable_v<_Fn, _Args...>; + + // [concept.regularinvocable], concept regular_invocable + template<typename _Fn, typename... _Args> + concept regular_invocable = invocable<_Fn, _Args...>; + + // [concept.predicate], concept predicate + template<typename _Fn, typename... _Args> + concept predicate = regular_invocable<_Fn, _Args...> + && boolean<invoke_result_t<_Fn, _Args...>>; + + // [concept.relation], concept relation + template<typename _Rel, typename _Tp, typename _Up> + concept relation + = predicate<_Rel, _Tp, _Tp> && predicate<_Rel, _Up, _Up> + && predicate<_Rel, _Tp, _Up> && predicate<_Rel, _Up, _Tp>; + + // [concept.strictweakorder], concept strict_weak_order + template<typename _Rel, typename _Tp, typename _Up> + concept strict_weak_order = relation<_Rel, _Tp, _Up>; + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif // C++2a + +#endif /* _GLIBCXX_CONCEPTS */ diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index f758bcd..21cc28b 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -153,6 +153,9 @@ #define __cpp_lib_atomic_ref 201806L #define __cpp_lib_bind_front 201907L #define __cpp_lib_bounded_array_traits 201902L +#if __cpp_concepts +# define __cpp_lib_concepts 201806L +#endif #define __cpp_lib_constexpr 201711L #define __cpp_lib_constexpr_algorithms 201806L #if __cpp_impl_destroying_delete diff --git a/libstdc++-v3/scripts/create_testsuite_files b/libstdc++-v3/scripts/create_testsuite_files index 40e81ce..52bbb5c 100755 --- a/libstdc++-v3/scripts/create_testsuite_files +++ b/libstdc++-v3/scripts/create_testsuite_files @@ -33,7 +33,7 @@ cd $srcdir # what has to happen when find(1) doesn't support -mindepth, or -xtype. # The directories here should be consistent with libstdc++-dg/conformance.exp dlist=`echo [0-9][0-9]*` -dlist="$dlist abi backward ext performance tr1 tr2 decimal experimental" +dlist="$dlist std abi backward ext performance tr1 tr2 decimal experimental" dlist="$dlist special_functions" find $dlist "(" -type f -o -type l ")" -name "*.cc" -print > $tmp.01 find $dlist "(" -type f -o -type l ")" -name "*.c" -print > $tmp.02 diff --git a/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp b/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp index 6564b04..f334f76 100644 --- a/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp +++ b/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp @@ -54,6 +54,7 @@ if {[info exists tests_file] && [file exists $tests_file]} { # Find directories that might have tests. # This list should be consistent with scripts/create_testsuite_files set subdirs [glob "$srcdir/\[0-9\]\[0-9\]*"] + lappend subdirs "$srcdir/std" lappend subdirs "$srcdir/abi" lappend subdirs "$srcdir/backward" lappend subdirs "$srcdir/ext" diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.callable/invocable.cc b/libstdc++-v3/testsuite/std/concepts/concepts.callable/invocable.cc new file mode 100644 index 0000000..d6a8549 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.callable/invocable.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( ! std::invocable<int> ); +static_assert( std::invocable<int()> ); +static_assert( std::invocable<int(*)()> ); +static_assert( std::invocable<int(&)()> ); +static_assert( ! std::invocable<int(), int> ); +static_assert( ! std::invocable<int() const> ); + +static_assert( std::invocable<int(const long*, short), long*, char> ); + +struct A; +static_assert( std::invocable<int A::*, const A&> ); +static_assert( ! std::invocable<void (A::*)(long&), const A*, long&> ); +static_assert( std::invocable<void (A::*)(long&) const, A*, long&> ); + +struct F +{ + void operator()() const; + void operator()(int); +}; +static_assert( std::invocable<F> ); +static_assert( std::invocable<F, int> ); +static_assert( std::invocable<const F&> ); +static_assert( ! std::invocable<const F&, int> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.callable/regular_invocable.cc b/libstdc++-v3/testsuite/std/concepts/concepts.callable/regular_invocable.cc new file mode 100644 index 0000000..f7ca447 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.callable/regular_invocable.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( ! std::regular_invocable<int> ); +static_assert( std::regular_invocable<int()> ); +static_assert( std::regular_invocable<int(*)()> ); +static_assert( std::regular_invocable<int(&)()> ); +static_assert( ! std::regular_invocable<int(), int> ); +static_assert( ! std::regular_invocable<int() const> ); + +static_assert( std::regular_invocable<int(const long*, short), long*, char> ); + +struct A; +static_assert( std::regular_invocable<int A::*, const A&> ); +static_assert( ! std::regular_invocable<void (A::*)(long&), const A*, long&> ); +static_assert( std::regular_invocable<void (A::*)(long&) const, A*, long&> ); + +struct F +{ + void operator()() const; + void operator()(int); +}; +static_assert( std::regular_invocable<F> ); +static_assert( std::regular_invocable<F, int> ); +static_assert( std::regular_invocable<const F&> ); +static_assert( ! std::regular_invocable<const F&, int> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.callable/relation.cc b/libstdc++-v3/testsuite/std/concepts/concepts.callable/relation.cc new file mode 100644 index 0000000..783c3ab --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.callable/relation.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( ! std::relation<bool, void, void> ); +static_assert( ! std::relation<bool(), void, void> ); +static_assert( ! std::relation<bool(*)(), void, void> ); +static_assert( ! std::relation<bool(&)(int, int), void, void> ); +static_assert( ! std::relation<bool(), int, int> ); +static_assert( ! std::relation<bool() const, int, int> ); + +static_assert( std::relation<bool(*)(int, int), short, long> ); +static_assert( std::relation<bool(&)(const void*, const void*), char[2], int*> ); + +static_assert( ! std::relation<bool& (const long*, short), long*, char> ); + +struct A; +static_assert( ! std::relation<int A::*, const A&, const A&> ); +static_assert( ! std::relation<void (A::*)(long&), const A*, long&> ); +static_assert( ! std::relation<void (A::*)(long&) const, A*, long&> ); +static_assert( std::relation<long (A::*)(A*) const, A*, A*> ); + +struct F +{ + void operator()(long, long) const; + bool& operator()(int, const int&) const; +}; +static_assert( ! std::relation<F, long, long> ); +static_assert( std::relation<F&, int, int> ); +static_assert( std::relation<const F&, const int, const int> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.callable/strictweakorder.cc b/libstdc++-v3/testsuite/std/concepts/concepts.callable/strictweakorder.cc new file mode 100644 index 0000000..9a01eb2 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.callable/strictweakorder.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( ! std::strict_weak_order<bool, void, void> ); +static_assert( ! std::strict_weak_order<bool(), void, void> ); +static_assert( ! std::strict_weak_order<bool(*)(), void, void> ); +static_assert( ! std::strict_weak_order<bool(&)(int, int), void, void> ); +static_assert( ! std::strict_weak_order<bool(), int, int> ); +static_assert( ! std::strict_weak_order<bool() const, int, int> ); + +static_assert( std::strict_weak_order<bool(*)(int, int), short, long> ); +static_assert( std::strict_weak_order<bool(&)(const void*, const void*), char[2], int*> ); + +static_assert( ! std::strict_weak_order<bool& (const long*, short), long*, char> ); + +struct A; +static_assert( ! std::strict_weak_order<int A::*, const A&, const A&> ); +static_assert( ! std::strict_weak_order<void (A::*)(long&), const A*, long&> ); +static_assert( ! std::strict_weak_order<void (A::*)(long&) const, A*, long&> ); +static_assert( std::strict_weak_order<long (A::*)(A*) const, A*, A*> ); + +struct F +{ + void operator()(long, long) const; + bool& operator()(int, const int&) const; +}; +static_assert( ! std::strict_weak_order<F, long, long> ); +static_assert( std::strict_weak_order<F&, int, int> ); +static_assert( std::strict_weak_order<const F&, const int, const int> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/floating_point.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/floating_point.cc new file mode 100644 index 0000000..802f237 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/floating_point.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::floating_point<float> ); +static_assert( std::floating_point<double> ); +static_assert( std::floating_point<long double> ); +#ifdef _GLIBCXX_USE_FLOAT128 +static_assert( std::floating_point<__float128> ); +#endif + +static_assert( !std::floating_point<char> ); +static_assert( !std::floating_point<signed char> ); +static_assert( !std::floating_point<bool> ); +static_assert( !std::floating_point<int> ); +static_assert( !std::floating_point<char32_t> ); + +#ifdef __GLIBCXX_TYPE_INT_N_0 +static_assert( !std::floating_point<signed __GLIBCXX_TYPE_INT_N_0> ); +#endif + +static_assert( !std::floating_point<void> ); +static_assert( !std::floating_point<float*> ); +static_assert( !std::floating_point<float&> ); +static_assert( !std::floating_point<float&&> ); +static_assert( !std::floating_point<const float&> ); +static_assert( !std::floating_point<float[]> ); +static_assert( !std::floating_point<float[2]> ); +static_assert( !std::floating_point<float()> ); +static_assert( !std::floating_point<float(*)()> ); +static_assert( !std::floating_point<float(&)()> ); + +enum E { }; +static_assert( !std::floating_point<E> ); +enum class CE { }; +static_assert( !std::floating_point<CE> ); +struct A { }; +static_assert( !std::floating_point<A> ); +union B { }; +static_assert( !std::floating_point<B> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc new file mode 100644 index 0000000..4716dde --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +// signed integer types +static_assert( std::integral<signed char> ); +static_assert( std::integral<signed short> ); +static_assert( std::integral<signed int> ); +static_assert( std::integral<signed long> ); +static_assert( std::integral<signed long long> ); + +// unsigned integer types +static_assert( std::integral<unsigned char> ); +static_assert( std::integral<unsigned short> ); +static_assert( std::integral<unsigned int> ); +static_assert( std::integral<unsigned long> ); +static_assert( std::integral<unsigned long long> ); + +// other integral types +static_assert( std::integral<bool> ); +static_assert( std::integral<char> ); +static_assert( std::integral<char16_t> ); +static_assert( std::integral<char32_t> ); +#ifdef _GLIBCXX_USE_WCHAR_T +static_assert( std::integral<wchar_t> ); +#endif +#ifdef _GLIBCXX_USE_CHAR8_T +static_assert( std::integral<char8_t> ); +#endif + +#ifdef __GLIBCXX_TYPE_INT_N_0 +static_assert( std::integral<signed __GLIBCXX_TYPE_INT_N_0> ); +static_assert( std::integral<unsigned __GLIBCXX_TYPE_INT_N_0> ); +#endif + +static_assert( !std::integral<void> ); +static_assert( !std::integral<float> ); +static_assert( !std::integral<int*> ); +static_assert( !std::integral<int&> ); +static_assert( !std::integral<int&&> ); +static_assert( !std::integral<const int&> ); +static_assert( !std::integral<int[]> ); +static_assert( !std::integral<int[2]> ); +static_assert( !std::integral<int()> ); +static_assert( !std::integral<int(*)()> ); +static_assert( !std::integral<int(&)()> ); + +enum E { }; +static_assert( !std::integral<E> ); +enum class CE { }; +static_assert( !std::integral<CE> ); +struct A { }; +static_assert( !std::integral<A> ); +union B { }; +static_assert( !std::integral<B> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/signed_integral.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/signed_integral.cc new file mode 100644 index 0000000..8dd33e5 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/signed_integral.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +// signed integer types +static_assert( std::signed_integral<signed char> ); +static_assert( std::signed_integral<signed short> ); +static_assert( std::signed_integral<signed int> ); +static_assert( std::signed_integral<signed long> ); +static_assert( std::signed_integral<signed long long> ); + +// unsigned integer types +static_assert( !std::signed_integral<unsigned char> ); +static_assert( !std::signed_integral<unsigned short> ); +static_assert( !std::signed_integral<unsigned int> ); +static_assert( !std::signed_integral<unsigned long> ); +static_assert( !std::signed_integral<unsigned long long> ); + +// other integral types +static_assert( !std::signed_integral<bool> ); +static_assert( std::is_signed_v<char> ? std::signed_integral<char> : true ); +static_assert( !std::signed_integral<char16_t> ); +static_assert( !std::signed_integral<char32_t> ); +#ifdef _GLIBCXX_USE_WCHAR_T +static_assert( std::is_signed_v<wchar_t> ? std::signed_integral<wchar_t> : true ); +#endif +#ifdef _GLIBCXX_USE_CHAR8_T +static_assert( !std::signed_integral<char8_t> ); +#endif + +#ifdef __GLIBCXX_TYPE_INT_N_0 +static_assert( std::signed_integral<signed __GLIBCXX_TYPE_INT_N_0> ); +static_assert( !std::signed_integral<unsigned __GLIBCXX_TYPE_INT_N_0> ); +#endif + +static_assert( !std::signed_integral<void> ); +static_assert( !std::signed_integral<float> ); +static_assert( !std::signed_integral<int&> ); +static_assert( !std::signed_integral<int&> ); +static_assert( !std::signed_integral<int&&> ); +static_assert( !std::signed_integral<const int&> ); +static_assert( !std::signed_integral<int[]> ); +static_assert( !std::signed_integral<int[2]> ); +static_assert( !std::signed_integral<int()> ); +static_assert( !std::signed_integral<int(*)()> ); +static_assert( !std::signed_integral<int(&)()> ); + +enum E { }; +static_assert( !std::signed_integral<E> ); +enum class CE { }; +static_assert( !std::signed_integral<CE> ); +struct A { }; +static_assert( !std::signed_integral<A> ); +union B { }; +static_assert( !std::signed_integral<B> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/unsigned_integral.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/unsigned_integral.cc new file mode 100644 index 0000000..33affff --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.arithmetic/unsigned_integral.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +// unsigned integer types +static_assert( std::unsigned_integral<unsigned char> ); +static_assert( std::unsigned_integral<unsigned short> ); +static_assert( std::unsigned_integral<unsigned int> ); +static_assert( std::unsigned_integral<unsigned long> ); +static_assert( std::unsigned_integral<unsigned long long> ); + +// signed integer types +static_assert( !std::unsigned_integral<signed char> ); +static_assert( !std::unsigned_integral<signed short> ); +static_assert( !std::unsigned_integral<signed int> ); +static_assert( !std::unsigned_integral<signed long> ); +static_assert( !std::unsigned_integral<signed long long> ); + +// other integral types +static_assert( std::unsigned_integral<bool> ); +static_assert( std::is_signed_v<char> ? true : std::unsigned_integral<char> ); +static_assert( std::unsigned_integral<char16_t> ); +static_assert( std::unsigned_integral<char32_t> ); +#ifdef _GLIBCXX_USE_WCHAR_T +static_assert( std::is_signed_v<wchar_t> ? true : std::unsigned_integral<wchar_t> ); +#endif +#ifdef _GLIBCXX_USE_CHAR8_T +static_assert( std::unsigned_integral<char8_t> ); +#endif + +#ifdef __GLIBCXX_TYPE_INT_N_0 +static_assert( !std::unsigned_integral<signed __GLIBCXX_TYPE_INT_N_0> ); +static_assert( std::unsigned_integral<unsigned __GLIBCXX_TYPE_INT_N_0> ); +#endif + +static_assert( !std::unsigned_integral<void> ); +static_assert( !std::unsigned_integral<float> ); +static_assert( !std::unsigned_integral<unsigned&> ); +static_assert( !std::unsigned_integral<unsigned&> ); +static_assert( !std::unsigned_integral<unsigned&&> ); +static_assert( !std::unsigned_integral<const unsigned&> ); +static_assert( !std::unsigned_integral<unsigned[]> ); +static_assert( !std::unsigned_integral<unsigned[2]> ); +static_assert( !std::unsigned_integral<unsigned()> ); +static_assert( !std::unsigned_integral<unsigned(*)()> ); +static_assert( !std::unsigned_integral<unsigned(&)()> ); + +enum E { }; +static_assert( !std::unsigned_integral<E> ); +enum class CE { }; +static_assert( !std::unsigned_integral<CE> ); +struct A { }; +static_assert( !std::unsigned_integral<A> ); +union B { }; +static_assert( !std::unsigned_integral<B> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.assignable/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.assignable/1.cc new file mode 100644 index 0000000..6477392 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.assignable/1.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( !std::assignable_from<void, void> ); +static_assert( !std::assignable_from<void*, int*> ); +static_assert( std::assignable_from<void*&, int*> ); +static_assert( !std::assignable_from<void*&, const int*> ); +static_assert( std::assignable_from<const void*&, const int*> ); +static_assert( !std::assignable_from<char, char> ); +static_assert( std::assignable_from<char&, char> ); +static_assert( !std::assignable_from<float, float> ); +static_assert( std::assignable_from<float&, double> ); +static_assert( std::assignable_from<int*&, int*> ); +static_assert( std::assignable_from<int&, int&> ); +static_assert( std::assignable_from<int&, int&&> ); +static_assert( !std::assignable_from<int&&, int> ); +static_assert( !std::assignable_from<const int&, int> ); +static_assert( !std::assignable_from<const int&, int&> ); +static_assert( !std::assignable_from<const int&, const int> ); +static_assert( !std::assignable_from<const int&, const int&> ); +static_assert( !std::assignable_from<int(&)[], int(&)[]> ); +static_assert( !std::assignable_from<int(&)[], int> ); +static_assert( !std::assignable_from<int(&)[2], int(&)[2]> ); +static_assert( !std::assignable_from<int(), int()> ); +static_assert( !std::assignable_from<int(*)(), int(*)()> ); +static_assert( std::assignable_from<int(*&)(), int(*)()> ); +static_assert( std::assignable_from<int(*&)(), std::nullptr_t> ); +static_assert( std::assignable_from<int(*&)(), int(*)() noexcept> ); +static_assert( std::assignable_from<int(*&)(), int(&)() noexcept> ); +static_assert( !std::assignable_from<int(&)(), std::nullptr_t> ); +static_assert( !std::assignable_from<int(&)(), int(&)() noexcept> ); + +enum E { }; +static_assert( !std::assignable_from<E, E> ); +static_assert( std::assignable_from<E&, E> ); +static_assert( std::assignable_from<E&, E&> ); +static_assert( std::assignable_from<E&, const E&> ); +static_assert( !std::assignable_from<const E&, const E&> ); +enum class CE { }; +static_assert( !std::assignable_from<CE, CE> ); +static_assert( std::assignable_from<CE&, CE&> ); +static_assert( std::assignable_from<CE&, const CE&> ); +static_assert( !std::assignable_from<const CE&, const CE&> ); +struct A { }; +static_assert( !std::assignable_from<A, A> ); +static_assert( std::assignable_from<A&, A> ); +static_assert( !std::assignable_from<A, A&> ); +static_assert( std::assignable_from<A&, const A&> ); +union B { }; +static_assert( !std::assignable_from<B, B> ); +static_assert( std::assignable_from<B&, B> ); +static_assert( !std::assignable_from<B, B&> ); +static_assert( std::assignable_from<B&, const B&> ); + +struct C +{ + C(int) { } + C& operator=(const C&) { return *this; } + C& operator=(int) { return *this; } + void operator=(void*) { } +}; +static_assert( std::assignable_from<C&, C> ); +static_assert( std::assignable_from<C&, const C&> ); +static_assert( std::assignable_from<C&, int> ); +static_assert( !std::assignable_from<C&, void*> ); +static_assert( !std::assignable_from<C&, std::nullptr_t> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.common/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.common/1.cc new file mode 100644 index 0000000..2432ab8 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.common/1.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::common_with<int, int> ); +static_assert( std::common_with<int, const int> ); +static_assert( std::common_with<int&&, const int&> ); +static_assert( std::common_with<int&, const int&&> ); +static_assert( std::common_with<void, void> ); +static_assert( ! std::common_with<int, void> ); +static_assert( ! std::common_with<int, int*> ); +static_assert( ! std::common_with<int, int()> ); + +static_assert( std::common_with<int, short> ); +static_assert( std::common_with<short, int> ); +static_assert( std::common_with<void*, const int*> ); + +struct A { A(int) { } }; +static_assert( std::common_with<A, int> ); + +struct B { }; +static_assert( ! std::common_with<A, B> ); + +struct C { C(const A&) { } }; +static_assert( std::common_with<A, C> ); +static_assert( std::common_with<A, const C> ); +static_assert( std::common_with<const A, C> ); +static_assert( std::common_with<const A, const C> ); + +struct D; +struct E { E(const D&) { } }; +struct D { D(const E&) { } }; +static_assert( ! std::common_with<D, E> ); // ambiguous conversion + +struct F { }; +struct G { }; +struct H { + H(const F&) { } + H(const G&) { } +}; +namespace std +{ + template<> struct common_type<F, G> { using type = H; }; + template<> struct common_type<G, F> { using type = H; }; +} + +static_assert( std::common_with<F, G> ); +static_assert( std::common_with<F, const G> ); +static_assert( std::common_with<const F, G> ); +static_assert( std::common_with<const F, const G> ); + +struct Base { }; +struct Derived : Base { }; +static_assert( std::common_with<Derived, Base> ); +static_assert( std::common_with<Derived*, Base*> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.commonref/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.commonref/1.cc new file mode 100644 index 0000000..4b56dd7 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.commonref/1.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::common_reference_with<int, int> ); +static_assert( std::common_reference_with<int, const int> ); +static_assert( std::common_reference_with<int&&, const int&> ); +static_assert( std::common_reference_with<int&, const int&&> ); +static_assert( ! std::common_reference_with<int, void> ); +static_assert( ! std::common_reference_with<int, int*> ); +static_assert( ! std::common_reference_with<int, int()> ); + +struct A { A(int) { } }; +static_assert( std::common_reference_with<A, int> ); + +struct B { }; +static_assert( ! std::common_reference_with<A, B> ); + +struct C { C(A&) { } }; +static_assert( std::common_reference_with<A&, C> ); +static_assert( std::common_reference_with<A&, C&&> ); +static_assert( std::common_reference_with<A&, const C&> ); +static_assert( std::common_reference_with<A&, C&> ); +static_assert( ! std::common_reference_with<const A&, C> ); +static_assert( ! std::common_reference_with<const A&, const C&> ); + +struct D; +struct E { E(D&) { } }; +struct D { D(E&) { } }; +static_assert( ! std::common_reference_with<D&, E&> ); // ambiguous conversion + +struct F; +struct G { G(const F&) { } }; +struct F { F(const G&) { } }; +namespace std +{ + template<template<typename> class Qual1, template<typename> class Qual2> + struct basic_common_reference<F, G, Qual1, Qual2> + { using type = Qual1<Qual2<F>>; }; + template<template<typename> class Qual1, template<typename> class Qual2> + struct basic_common_reference<G, F, Qual1, Qual2> + { using type = Qual1<Qual2<F>>; }; +} + +static_assert( ! std::common_reference_with<F&, G&> ); +static_assert( std::common_reference_with<F, G> ); +static_assert( std::common_reference_with<F, const G> ); +static_assert( std::common_reference_with<const F, const G> ); + +struct Base { }; +struct Derived : Base { }; +static_assert( std::common_reference_with<Derived&, Base&> ); +static_assert( std::common_with<Derived*, Base*> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.constructible/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.constructible/1.cc new file mode 100644 index 0000000..22a52d0 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.constructible/1.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( !std::constructible_from<void> ); +static_assert( !std::constructible_from<void, void> ); +static_assert( std::constructible_from<void*, int*> ); +static_assert( !std::constructible_from<void*, const int*> ); +static_assert( std::constructible_from<const void*, const int*> ); +static_assert( std::constructible_from<char> ); +static_assert( std::constructible_from<float> ); +static_assert( std::constructible_from<float, float> ); +static_assert( std::constructible_from<float, double> ); +static_assert( std::constructible_from<int*> ); +static_assert( std::constructible_from<int*, int*> ); +static_assert( !std::constructible_from<int&> ); +static_assert( std::constructible_from<int&, int&> ); +static_assert( !std::constructible_from<int&&> ); +static_assert( std::constructible_from<int&&, int> ); +static_assert( !std::constructible_from<const int&> ); +static_assert( std::constructible_from<const int&, int> ); +static_assert( std::constructible_from<const int&, int&> ); +static_assert( std::constructible_from<const int&, const int> ); +static_assert( std::constructible_from<const int&, const int&> ); +static_assert( !std::constructible_from<const int&, int, int> ); +static_assert( !std::constructible_from<int[]> ); +static_assert( std::constructible_from<int[2]> ); +static_assert( !std::constructible_from<int()> ); +static_assert( std::constructible_from<int(*)()> ); +static_assert( std::constructible_from<int(*)(), std::nullptr_t> ); +static_assert( std::constructible_from<int(*)(), int(*)() noexcept> ); +static_assert( std::constructible_from<int(*)(), int(&)() noexcept> ); +static_assert( !std::constructible_from<int(&)()> ); +static_assert( std::constructible_from<int(&)(), int(&)() noexcept> ); + +enum E { }; +static_assert( std::constructible_from<E> ); +static_assert( std::constructible_from<E, E&> ); +enum class CE { }; +static_assert( std::constructible_from<CE> ); +static_assert( std::constructible_from<CE, CE&> ); +struct A { }; +static_assert( std::constructible_from<A> ); +static_assert( std::constructible_from<A, A> ); +static_assert( std::constructible_from<A, A&> ); +static_assert( std::constructible_from<A, const A&> ); +union B { }; +static_assert( std::constructible_from<B> ); +static_assert( std::constructible_from<B, B> ); +static_assert( std::constructible_from<B, B&> ); +static_assert( std::constructible_from<B, const B&> ); + +struct C +{ + C(void* = nullptr) { } + ~C() noexcept(false) { } +}; +static_assert( !std::constructible_from<C> ); +static_assert( !std::constructible_from<C, void*> ); +static_assert( !std::constructible_from<C, std::nullptr_t> ); + +class D +{ +public: + D() { } + D(int) { } +private: + ~D() { } +}; +static_assert( !std::constructible_from<D> ); +static_assert( !std::constructible_from<D, int> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.convertible/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.convertible/1.cc new file mode 100644 index 0000000..295706c --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.convertible/1.cc @@ -0,0 +1,77 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::convertible_to<int, int> ); +static_assert( std::convertible_to<int&, int> ); +static_assert( !std::convertible_to<int, int&> ); +static_assert( std::convertible_to<int, const int&> ); +static_assert( !std::convertible_to<int&&, int&> ); +static_assert( std::convertible_to<int&&, const int&> ); +static_assert( std::convertible_to<const int, int> ); +static_assert( !std::convertible_to<const int, int&> ); +static_assert( std::convertible_to<const int, const int> ); +static_assert( std::convertible_to<const int, const int&> ); + +static_assert( std::convertible_to<int, float> ); +static_assert( !std::convertible_to<int, float&> ); +static_assert( !std::convertible_to<int, int*> ); +static_assert( std::convertible_to<int*, void*> ); +static_assert( std::convertible_to<int*, const void*> ); +static_assert( !std::convertible_to<const int*, void*> ); +static_assert( !std::convertible_to<int, void> ); + +struct A { }; +static_assert( std::convertible_to<A, A> ); +static_assert( std::convertible_to<A, const A> ); +static_assert( std::convertible_to<A const, const A> ); +static_assert( !std::convertible_to<volatile A, const A> ); +static_assert( !std::convertible_to<volatile A, const volatile A&> ); +static_assert( std::convertible_to<volatile A&, const volatile A&> ); + +struct B : A { }; +static_assert( !std::convertible_to<A, B> ); +static_assert( std::convertible_to<B, A> ); +static_assert( std::convertible_to<const B, A> ); +static_assert( std::convertible_to<B, const A> ); +static_assert( std::convertible_to<B, const A&> ); +static_assert( !std::convertible_to<volatile B, const A> ); +static_assert( !std::convertible_to<volatile B, const A&> ); + +struct C : private A { }; +static_assert( !std::convertible_to<A, C> ); +static_assert( !std::convertible_to<C, A> ); + +struct D : A { }; +struct E : B, D { }; +static_assert( !std::convertible_to<A, E> ); +static_assert( !std::convertible_to<E, A> ); + +struct F +{ + F(A) { } + F(C&&) { } +}; +static_assert( std::convertible_to<A, F> ); +static_assert( std::convertible_to<const A, F> ); +static_assert( std::convertible_to<C, F> ); +static_assert( !std::convertible_to<C&, F> ); +static_assert( !std::convertible_to<const C, F> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.copyconstructible/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.copyconstructible/1.cc new file mode 100644 index 0000000..0e7843e --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.copyconstructible/1.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( !std::copy_constructible<void> ); +static_assert( std::copy_constructible<void*> ); +static_assert( std::copy_constructible<const void*> ); +static_assert( std::copy_constructible<char> ); +static_assert( std::copy_constructible<const float> ); +static_assert( std::copy_constructible<int*> ); +static_assert( std::copy_constructible<int&> ); +static_assert( !std::copy_constructible<int&&> ); +static_assert( std::copy_constructible<const int&> ); +static_assert( !std::copy_constructible<int[]> ); +static_assert( !std::copy_constructible<int[2]> ); +static_assert( !std::copy_constructible<int()> ); +static_assert( std::copy_constructible<int(*)()> ); +static_assert( std::copy_constructible<int(&)()> ); +static_assert( std::copy_constructible<int(&)() noexcept> ); + +enum E { }; +static_assert( std::copy_constructible<E> ); +enum class CE { }; +static_assert( std::copy_constructible<CE> ); +struct A { }; +static_assert( std::copy_constructible<A> ); +union B { }; +static_assert( std::copy_constructible<B> ); + +struct C +{ + C(void* = nullptr) { } + ~C() noexcept(false) { } +}; +static_assert( !std::copy_constructible<C> ); + +class D +{ +public: + D() { } + D(int) { } +private: + ~D() { } +}; +static_assert( !std::copy_constructible<D> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.defaultconstructible/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.defaultconstructible/1.cc new file mode 100644 index 0000000..56a4844 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.defaultconstructible/1.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( !std::default_constructible<void> ); +static_assert( std::default_constructible<void*> ); +static_assert( std::default_constructible<const void*> ); +static_assert( std::default_constructible<char> ); +static_assert( std::default_constructible<float> ); +static_assert( std::default_constructible<const int> ); +static_assert( std::default_constructible<int*> ); +static_assert( !std::default_constructible<int&> ); +static_assert( !std::default_constructible<int&&> ); +static_assert( !std::default_constructible<const int&> ); +static_assert( !std::default_constructible<int[]> ); +static_assert( std::default_constructible<int[2]> ); +static_assert( !std::default_constructible<int()> ); +static_assert( std::default_constructible<int(*)()> ); +static_assert( !std::default_constructible<int(&)()> ); + +enum E { }; +static_assert( std::default_constructible<E> ); +enum class CE { }; +static_assert( std::default_constructible<CE> ); +struct A { }; +static_assert( std::default_constructible<A> ); +union B { }; +static_assert( std::constructible_from<B> ); + +struct C +{ + C(void* = nullptr) { } + ~C() noexcept(false) { } +}; +static_assert( !std::default_constructible<C> ); + +class D +{ +public: + D() { } + D(int) { } +private: + ~D() { } +}; +static_assert( !std::default_constructible<D> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.derived/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.derived/1.cc new file mode 100644 index 0000000..f376aee --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.derived/1.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( !std::derived_from<int, int> ); +static_assert( !std::derived_from<int&, int> ); +static_assert( !std::derived_from<int, int&> ); +static_assert( !std::derived_from<int&&, int&> ); +static_assert( !std::derived_from<const int, int> ); +static_assert( !std::derived_from<const int, const int> ); + +struct A { }; +static_assert( std::derived_from<A, A> ); +static_assert( std::derived_from<A, const A> ); +static_assert( std::derived_from<A const, const A> ); +static_assert( std::derived_from<volatile A, const A> ); + +struct B : A { }; +static_assert( !std::derived_from<A, B> ); +static_assert( std::derived_from<B, A> ); +static_assert( std::derived_from<const B, A> ); +static_assert( std::derived_from<B, const A> ); +static_assert( std::derived_from<volatile B, const A> ); + +struct C : private A { }; +static_assert( !std::derived_from<A, C> ); +static_assert( !std::derived_from<C, A> ); + +struct D : A { }; +struct E : B, D { }; +static_assert( !std::derived_from<A, E> ); +static_assert( !std::derived_from<E, A> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.destructible/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.destructible/1.cc new file mode 100644 index 0000000..279072a --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.destructible/1.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( !std::destructible<void> ); +static_assert( std::destructible<char> ); +static_assert( std::destructible<float> ); +static_assert( std::destructible<int*> ); +static_assert( std::destructible<int&> ); +static_assert( std::destructible<int&&> ); +static_assert( std::destructible<const int&> ); +static_assert( !std::destructible<int[]> ); +static_assert( std::destructible<int[2]> ); +static_assert( !std::destructible<int()> ); +static_assert( std::destructible<int(*)()> ); +static_assert( std::destructible<int(&)()> ); + +enum E { }; +static_assert( std::destructible<E> ); +enum class CE { }; +static_assert( std::destructible<CE> ); +struct A { }; +static_assert( std::destructible<A> ); +union B { }; +static_assert( std::destructible<B> ); + +struct C +{ + ~C() noexcept(false) { } +}; +static_assert( !std::destructible<C> ); +class D +{ +public: + D() { } +private: + ~D() { } +}; +static_assert( !std::destructible<D> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.moveconstructible/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.moveconstructible/1.cc new file mode 100644 index 0000000..9bdf87b --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.moveconstructible/1.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( !std::move_constructible<void> ); +static_assert( std::move_constructible<void*> ); +static_assert( std::move_constructible<const void*> ); +static_assert( std::move_constructible<char> ); +static_assert( std::move_constructible<const float> ); +static_assert( std::move_constructible<int*> ); +static_assert( std::move_constructible<int&> ); +static_assert( std::move_constructible<int&&> ); +static_assert( std::move_constructible<const int&> ); +static_assert( !std::move_constructible<int[]> ); +static_assert( !std::move_constructible<int[2]> ); +static_assert( !std::move_constructible<int()> ); +static_assert( std::move_constructible<int(*)()> ); +static_assert( std::move_constructible<int(&)()> ); +static_assert( std::move_constructible<int(&)() noexcept> ); + +enum E { }; +static_assert( std::move_constructible<E> ); +enum class CE { }; +static_assert( std::move_constructible<CE> ); +struct A { }; +static_assert( std::move_constructible<A> ); +union B { }; +static_assert( std::move_constructible<B> ); + +struct C +{ + C(void* = nullptr) { } + ~C() noexcept(false) { } +}; +static_assert( !std::move_constructible<C> ); + +class D +{ +public: + D() { } + D(int) { } +private: + ~D() { } +}; +static_assert( !std::move_constructible<D> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.same/1.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.same/1.cc new file mode 100644 index 0000000..dfb66f4 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.same/1.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::same_as<int, int> ); +static_assert( !std::same_as<int&, int> ); +static_assert( !std::same_as<int, int&> ); +static_assert( !std::same_as<int&&, int&> ); +static_assert( !std::same_as<const int, int> ); +static_assert( std::same_as<const int, const int> ); + +struct A { }; +static_assert( std::same_as<A, A> ); +static_assert( !std::same_as<A, const A> ); +static_assert( std::same_as<A const, const A> ); +static_assert( !std::same_as<volatile A, const A> ); + +struct B : A { }; +static_assert( !std::same_as<A, B> ); + +template<typename T, typename U> + constexpr int + check_subsumption() + { return 0; } + +template<typename T, typename U> + requires std::same_as<T, U> + constexpr int + check_subsumption() + { return 1; } + +template<typename T, typename U> + requires std::same_as<U, T> && std::is_const_v<T> + constexpr int + check_subsumption() + { return 2; } + +template<typename T, typename U> + requires std::same_as<U, T> && std::is_volatile_v<T> + constexpr int + check_subsumption() + { return 3; } + +static_assert( check_subsumption<short, long>() == 0 ); +static_assert( check_subsumption<unsigned, unsigned>() == 1 ); +// These will be ambiguous if same_as<T,U> doesn't subsume same_as<U,T>: +static_assert( check_subsumption<const char, const char>() == 2 ); +static_assert( check_subsumption<volatile int, volatile int>() == 3 ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc new file mode 100644 index 0000000..0b7f28c --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc @@ -0,0 +1,78 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +namespace nu +{ + struct S { bool swapped = false; }; + constexpr void swap(S& l, S& r) { l.swapped = r.swapped = true; } + struct T { int i; }; + + union U { char c; int i; }; + constexpr void swap(U& l, U& r) { l.i = r.i = 99; } +} + +constexpr bool check_struct_with_adl_swap(int i) +{ + nu::S s1, s2; + std::ranges::swap(s1, s2); + return s1.swapped && s2.swapped; +} + +static_assert(check_struct_with_adl_swap(1)); + +constexpr bool check_array_with_adl_swap(int i) +{ + nu::S s1[2], s2[2]; + std::ranges::swap(s1, s2); + return s1[0].swapped && s2[0].swapped && s1[1].swapped && s2[1].swapped; +} + +static_assert(check_array_with_adl_swap(1)); + +constexpr bool check_struct_without_adl_swap(int i) +{ + nu::T t1{i}, t2{2*i}; + std::ranges::swap(t1, t2); + return t1.i == 2*i && t2.i == i; +} + +static_assert(check_struct_without_adl_swap(1)); + +constexpr bool check_array_without_adl_swap(int i) +{ + nu::T t1[2]{i, 2*i}, t2[2]{3*i, 4*i}; + std::ranges::swap(t1, t2); + return t1[0].i == 3*i && t2[0].i == i && t1[1].i == 4*i && t2[1].i == 2*i; +} + +static_assert(check_array_without_adl_swap(1)); + + +constexpr bool check_union_with_adl_swap(int i) +{ + nu::U u1{}, u2{}; + u1.i = u2.i = i; + std::ranges::swap(u1, u2); + return u1.i == 99 && u2.i == 99; +} + +static_assert(check_union_with_adl_swap(1)); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc new file mode 100644 index 0000000..b5a3024 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +namespace nu +{ + struct S { bool swapped = false; }; + constexpr void swap(S& l, S& r) { } + struct T { int i; }; + + union U { char c; int i; }; + constexpr void swap(U& l, U& r) { } +} + +static_assert( std::swappable<nu::S> ); +static_assert( !std::swappable<const nu::S> ); +static_assert( std::swappable<nu::T> ); +static_assert( !std::swappable<const nu::T> ); +static_assert( std::swappable<nu::U> ); +static_assert( !std::swappable<const nu::U> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable_with.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable_with.cc new file mode 100644 index 0000000..7d1147f --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable_with.cc @@ -0,0 +1,80 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::swappable_with<int&, int&> ); +static_assert( ! std::swappable_with<int, int> ); +static_assert( ! std::swappable_with<int*, int*> ); +static_assert( ! std::swappable_with<int&, const int&> ); +static_assert( ! std::swappable_with<const int&, const int&> ); +static_assert( ! std::swappable_with<int&, long&> ); + +namespace N1 +{ + struct Immovable + { + Immovable() = default; + Immovable(Immovable&&) = delete; + }; +} +static_assert( ! std::swappable_with<N1::Immovable&, N1::Immovable&> ); + +namespace N2 +{ + struct Swappable + { + Swappable() = default; + Swappable(Swappable&&) = delete; + friend void swap(Swappable&, Swappable&) { } + }; +} +static_assert( std::swappable_with<N2::Swappable&, N2::Swappable&> ); + +namespace N3 +{ + struct A { }; + struct Proxy { + Proxy(A&) { } + friend void swap(Proxy, Proxy) { } + }; +} + +static_assert( std::swappable_with<N3::A&, N3::A&> ); +static_assert( std::swappable_with<N3::A&, N3::Proxy> ); +static_assert( std::swappable_with<N3::Proxy, N3::A&> ); +static_assert( std::swappable_with<N3::Proxy, N3::Proxy> ); + +struct C { C(int&) { } }; +void swap(int&, C&) { } // not symmetrical +static_assert( ! std::swappable_with<int, C> ); +static_assert( ! std::swappable_with<C, int> ); + +struct D { D(int&) { } }; +void swap(int&, D&) { } +void swap(D&&, int&) { } // only accepts rvalues +static_assert( ! std::swappable_with<int&, D> ); +static_assert( ! std::swappable_with<D, int> ); + +struct E { E(int&) { } }; +void swap(int, E&&) { } // only accepts rvalues +void swap(E&, int) { } +static_assert( ! std::swappable_with<int, E> ); +static_assert( ! std::swappable_with<E, int> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.object/copyable.cc b/libstdc++-v3/testsuite/std/concepts/concepts.object/copyable.cc new file mode 100644 index 0000000..abb1689 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.object/copyable.cc @@ -0,0 +1,108 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::copyable<int> ); +static_assert( std::copyable<int*> ); +static_assert( ! std::copyable<int&> ); +static_assert( ! std::copyable<void> ); +static_assert( ! std::copyable<void()> ); +static_assert( ! std::copyable<void() noexcept> ); +static_assert( ! std::copyable<void() const> ); + +struct Trivial { }; +static_assert( std::copyable<Trivial> ); + +struct NotTrivial +{ + NotTrivial(int) { } + NotTrivial(const NotTrivial&) { } + NotTrivial& operator=(const NotTrivial&) { return *this; } + ~NotTrivial() { } +}; +static_assert( std::copyable<NotTrivial> ); + +namespace N1 +{ + struct Immovable + { + Immovable() = default; + Immovable(Immovable&&) = delete; + }; +} +static_assert( ! std::copyable<N1::Immovable> ); + +struct Movable +{ + Movable() = default; + Movable(Movable&&) = default; + Movable& operator=(Movable&&) = default; +}; +static_assert( ! std::copyable<Movable> ); + +struct MovableAndCopyAssignable +{ + MovableAndCopyAssignable() = default; + MovableAndCopyAssignable(MovableAndCopyAssignable&&) = default; + MovableAndCopyAssignable& operator=(MovableAndCopyAssignable&&) = default; + MovableAndCopyAssignable& operator=(const MovableAndCopyAssignable&) = default; +}; +static_assert( ! std::copyable<MovableAndCopyAssignable> ); + +struct MovableAndCopyConstructible +{ + MovableAndCopyConstructible() = default; + MovableAndCopyConstructible(MovableAndCopyConstructible&&) = default; + MovableAndCopyConstructible(const MovableAndCopyConstructible&) = default; + MovableAndCopyConstructible& operator=(MovableAndCopyConstructible&&) = default; +}; +static_assert( ! std::copyable<MovableAndCopyConstructible> ); + +namespace N2 +{ + struct Swappable + { + Swappable() = default; + Swappable(Swappable&&) = default; + friend void swap(Swappable&, Swappable&) { } + }; +} +static_assert( ! std::copyable<N2::Swappable> ); + +struct NotAssignable +{ + NotAssignable() = default; + NotAssignable(NotAssignable&&) = default; + NotAssignable& operator=(NotAssignable&&) = default; + NotAssignable(const NotAssignable&) = default; + NotAssignable& operator=(const NotAssignable&) = delete; + friend void swap(NotAssignable&, NotAssignable&) { } +}; +static_assert( ! std::copyable<NotAssignable> ); + +struct NotSwappable +{ + NotSwappable() = default; + NotSwappable(const NotSwappable&) = default; + NotSwappable& operator=(const NotSwappable&) = default; +}; +void swap(NotSwappable&, NotSwappable&) = delete; +static_assert( std::copyable<NotSwappable> ); // ranges::swap still works! diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.object/movable.cc b/libstdc++-v3/testsuite/std/concepts/concepts.object/movable.cc new file mode 100644 index 0000000..48fddc1 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.object/movable.cc @@ -0,0 +1,81 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::movable<int> ); +static_assert( std::movable<int*> ); +static_assert( ! std::movable<int&> ); +static_assert( ! std::movable<void> ); +static_assert( ! std::movable<void()> ); +static_assert( ! std::movable<void() noexcept> ); +static_assert( ! std::movable<void() const> ); + +struct Trivial { }; +static_assert( std::movable<Trivial> ); + +struct NotTrivial +{ + NotTrivial(int) { } + NotTrivial(NotTrivial&&) { } + NotTrivial& operator=(NotTrivial&&) { return *this; } + ~NotTrivial() { } +}; +static_assert( std::movable<NotTrivial> ); + +namespace N1 +{ + struct Immovable + { + Immovable() = default; + Immovable(Immovable&&) = delete; + }; +} +static_assert( ! std::movable<N1::Immovable> ); + +namespace N2 +{ + struct Swappable + { + Swappable() = default; + Swappable(Swappable&&) = delete; + Swappable& operator=(Swappable&&) = default; + friend void swap(Swappable&, Swappable&) { } + }; +} +static_assert( ! std::movable<N2::Swappable> ); + +struct NotAssignable +{ + NotAssignable() = default; + NotAssignable(NotAssignable&&) = default; + NotAssignable& operator=(NotAssignable&&) = delete; + friend void swap(NotAssignable&, NotAssignable&) { } +}; +static_assert( ! std::movable<NotAssignable> ); + +struct NotSwappable +{ + NotSwappable() = default; + NotSwappable(NotSwappable&&) = default; + NotSwappable& operator=(NotSwappable&&) = default; +}; +void swap(NotSwappable&, NotSwappable&) = delete; +static_assert( std::movable<NotSwappable> ); // ranges::swap still works! diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.object/regular.cc b/libstdc++-v3/testsuite/std/concepts/concepts.object/regular.cc new file mode 100644 index 0000000..338cf1b --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.object/regular.cc @@ -0,0 +1,64 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::regular<int> ); +static_assert( std::regular<int*> ); +static_assert( ! std::regular<int&> ); +static_assert( ! std::regular<void> ); +static_assert( ! std::regular<void()> ); +static_assert( ! std::regular<void() noexcept> ); +static_assert( ! std::regular<void() const> ); + +struct Trivial { }; +static_assert( ! std::regular<Trivial> ); + +struct NotTrivial +{ + NotTrivial() { } + ~NotTrivial() { } +}; +static_assert( ! std::regular<NotTrivial> ); + +struct NotDefaultConstructible +{ + NotDefaultConstructible(int) { } +}; +static_assert( ! std::regular<NotDefaultConstructible> ); + +struct HasReference +{ + int& ref; +}; +static_assert( ! std::regular<HasReference> ); + +struct HasEq { }; +bool operator==(HasEq, HasEq) { return true; } +#ifdef __cpp_lib_three_way_comparison +static_assert( std::regular<HasEq> ); +#else +static_assert( ! std::regular<HasEq> ); +#endif + +struct HasEqNeq { }; +bool operator==(HasEqNeq, HasEqNeq) { return true; } +bool operator!=(HasEqNeq, HasEqNeq) { return false; } +static_assert( std::regular<HasEqNeq> ); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.object/semiregular.cc b/libstdc++-v3/testsuite/std/concepts/concepts.object/semiregular.cc new file mode 100644 index 0000000..1e095d6 --- /dev/null +++ b/libstdc++-v3/testsuite/std/concepts/concepts.object/semiregular.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2019 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++2a" } +// { dg-do compile { target c++2a } } + +#include <concepts> + +static_assert( std::semiregular<int> ); +static_assert( std::semiregular<int*> ); +static_assert( ! std::semiregular<int&> ); +static_assert( ! std::semiregular<void> ); +static_assert( ! std::semiregular<void()> ); +static_assert( ! std::semiregular<void() noexcept> ); +static_assert( ! std::semiregular<void() const> ); + +struct Trivial { }; +static_assert( std::semiregular<Trivial> ); + +struct NotTrivial +{ + NotTrivial() { } + ~NotTrivial() { } +}; +static_assert( std::semiregular<NotTrivial> ); + +struct NotDefaultConstructible +{ + NotDefaultConstructible(int) { } +}; +static_assert( ! std::semiregular<NotDefaultConstructible> ); + +struct HasReference +{ + int& ref; +}; +static_assert( ! std::semiregular<HasReference> ); |