Commit Graph

677 Commits

Author SHA1 Message Date
Jonathan Wakely 31ceab27a8 PR libstdc++/83427 detect weak result type from noexcept functions
PR libstdc++/83427
	* include/bits/refwrap.h (_Weak_result_type_impl)
	(_Reference_wrapper_base): Deduce noexcept for function types.
	* testsuite/20_util/bind/83427.cc: New test.
	* testsuite/20_util/reference_wrapper/83427.cc: New test.

From-SVN: r255652
2017-12-14 17:29:22 +00:00
Jonathan Wakely 4fb43923ef PR libstdc++/83395 fix invocable traits for INVOKE<cv void>
PR libstdc++/83395
	* include/std/type_traits (__is_invocable_impl): Remove partial
	specialization for INVOKE<void> and restore is_void<R> check in
	primary template.
	(__is_nt_invocable_impl): Likewise.
	* testsuite/20_util/is_invocable/83395.cc: New test.
	* testsuite/20_util/is_nothrow_invocable/83395.cc: New test.

From-SVN: r255585
2017-12-12 18:07:24 +00:00
Jonathan Wakely 2a8f244b91 PR libstdc++/83134 Ensure std::__not_ converts B::value to bool
Backport from mainline
2017-11-23  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/83134
	* include/std/type_traits (__not_): Explicitly convert to bool.
	* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error.
	* testsuite/20_util/logical_traits/83134.cc: New test.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust
	dg-error.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.

From-SVN: r255329
2017-12-01 17:12:23 +00:00
Jonathan Wakely dc0d363ff9 Update value of __cpp_lib_chrono feature-test macro
* include/std/chrono (__cpp_lib_chrono): Update macro value to
	indicate support for P0505R0.
	* testsuite/20_util/duration/arithmetic/constexpr_c++17.cc: Check
	for updated macro.

From-SVN: r253960
2017-10-20 22:06:20 +01:00
Jonathan Wakely 7759a387e2 PR libstdc++/79433 no #error for including headers with wrong -std
Backport from mainline
2017-09-12  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/79433
	* doc/xml/manual/status_cxx2017.xml: Update feature-test macros.
	* doc/html/*: Regenerate.
	* include/Makefile.am: Remove <bits/c++17_warning.h>.
	* include/Makefile.in: Regenerate.
	* include/bits/c++17_warning.h: Remove.
	* include/bits/string_view.tcc: Do not include <bits/c++17_warning.h>
	for pre-C++17 modes.
	* include/std/any: Likewise.
	(__cpp_lib_any): Define.
	* include/std/mutex (__cpp_lib_scoped_lock): Adjust value as per new
	SD-6 draft.
	* include/std/numeric (__cpp_lib_gcd_lcm): Define as per new SD-6
	draft.
	* include/std/optional: Do not include <bits/c++17_warning.h>.
	(__cpp_lib_optional): Define.
	* include/std/shared_mutex: Do not include <bits/c++14_warning.h>.
	* include/std/string_view: Do not include <bits/c++17_warning.h>.
	(__cpp_lib_string_view): Define.
	* include/std/variant: Do not include <bits/c++17_warning.h>.
	(__cpp_lib_variant): Define.
	* testsuite/20_util/optional/cons/value_neg.cc: Adjust dg-error line
	numbers.
	* testsuite/26_numerics/gcd/1.cc: Test for __cpp_lib_gcd_lcm.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error line
	numbers.
	* testsuite/26_numerics/lcm/1.cc: Test for __cpp_lib_gcd_lcm.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Adjust dg-error line
	numbers.
	* testsuite/30_threads/scoped_lock/requirements/typedefs.cc: Adjust
	expected value of __cpp_lib_scoped_lock.

From-SVN: r253943
2017-10-20 16:14:29 +01:00
Jonathan Wakely 6c8a90ba12 PR libstdc++/82262 fix std::hash<std::optional<const T>>
PR libstdc++/82262
	* include/std/optional (__optional_hash_call_base): Add template
	parameter for remove_const_t<_Tp> and use it consistently.
	* testsuite/20_util/optional/hash.cc: Test optional<const T>.

From-SVN: r253015
2017-09-20 15:22:29 +01:00
Jonathan Wakely 598c1fda3c PR libstdc++/82254 fix std::is_nothrow_invocable_r w.r.t throwing conversions
PR libstdc++/82254
	* include/std/type_traits (__is_invocable): Add partial specialization
	for INVOKE<void> case and remove is_void<R> check from partial
	specialization for INVOKE<R> case.
	(__is_nt_invocable_impl): New helper for is_nothrow_invocable_r.
	(is_nothrow_invocable_r): Use __is_nt_invocable_impl.
	* testsuite/20_util/is_nothrow_invocable/value.cc: Add tests for
	conversions that can throw or fail to convert. Use static assert
	strings to explain negative results.
	* testsuite/20_util/is_nothrow_invocable/value_ext.cc: Use
	is_nothrow_constructible in is_nt_invocable_conv.

From-SVN: r253014
2017-09-20 15:22:25 +01:00
Jonathan Wakely c2f99c9d9a PR libstdc++/81468 constrain std::chrono::time_point constructor
PR libstdc++/81468
	* include/std/chrono (time_point(const time_point<_Dur2>&)): Add
	missing constraint from LWG DR 1177.
	* testsuite/20_util/duration/cons/dr1177.cc: New.
	* testsuite/20_util/time_point/cons/81468.cc: New.
	* testsuite/20_util/duration/literals/range.cc: Update dg-error line.

From-SVN: r252090
2017-09-13 16:20:21 +01:00
Jonathan Wakely 371868a847 Support move-only deleters in std::shared_ptr (LWG 2802)
Backport from mainline
2017-06-09  Jonathan Wakely  <jwakely@redhat.com>

	* doc/xml/manual/intro.xml: Document LWG 2802, 2873 and 2942 changes.
	* include/bits/shared_ptr.h (shared_ptr): Use rvalues for deleters
	(LWG 2802).
	* include/bits/shared_ptr_base.h (_Sp_ebo_helper, _Sp_counted_deleter
	(_Sp_counted_deleter::_Impl, __shared_count, __shared_ptr): Likewise.
	* testsuite/20_util/shared_ptr/cons/lwg2802.cc: New.

From-SVN: r250541
2017-07-25 19:05:25 +01:00
Jonathan Wakely dea4c7435c Add noexcept to shared_ptr owner comparisons (LWG 2873)
Backport from mainline
2017-06-05  Jonathan Wakely  <jwakely@redhat.com>

	* include/bits/shared_ptr_base.h (__shared_ptr::owner_before)
	(__weak_ptr::owner_before, _Sp_owner_less::operator()): Add noexcept
	specifiers as per LWG 2873 and LWG 2942.
	* testsuite/20_util/owner_less/noexcept.cc: New.
	* testsuite/20_util/shared_ptr/observers/owner_before.cc: Test
	noexcept guarantees.
	* testsuite/20_util/weak_ptr/observers/owner_before.cc: Likewise.

From-SVN: r250540
2017-07-25 19:05:19 +01:00
Jonathan Wakely b65b227362 PR libstdc++/80553 don't allow destroying non-destructible types
Backport from mainline
2017-04-28  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/80553
	* include/bits/stl_construct.h (_Destroy, _Destroy_n): Add static
	assertions to ensure type is destructible.
	(destroy_at, destroy, destroy_n): Move from stl_uninitialized.h.
	* include/bits/stl_uninitialized.h (destroy_at, destroy, destroy_n):
	Move to stl_construct.h.
	* testsuite/20_util/specialized_algorithms/memory_management_tools/
	destroy_neg.cc: New test.
	* testsuite/23_containers/vector/cons/destructible_neg.cc: New test.

From-SVN: r250539
2017-07-25 19:05:13 +01:00
Jonathan Wakely 2f484ee274 PR libstdc++/81017 add noexcept to std::function move operations
Backport from mainline
2017-06-08  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/81017
	* include/bits/std_function.h (function::function(function&&))
	(function::operator=(funtion&&)): Add noexcept.
	* testsuite/20_util/function/assign/move.cc: Check for noexcept.
	* testsuite/20_util/function/cons/move.cc: Likewise.

From-SVN: r250536
2017-07-25 19:04:54 +01:00
Jonathan Wakely 8b6fb0e81f Constrain std::variant constructor for class template argument deduction
Backport from mainline
2017-07-14  Jason Merrill  <jason@redhat.com>
    Jonathan Wakely  <jwakely@redhat.com>

	* include/std/variant (variant::variant(_Tp&&)): Constrain to remove
	the constructor for empty variants from the candidate functions
	during class template argument deduction.
	* testsuite/20_util/variant/deduction.cc: New.

From-SVN: r250534
2017-07-25 19:04:38 +01:00
Jonathan Wakely e83fef1f15 PR libstdc++/80737 backport std::variant fix from mainline
Backport from mainline
2017-05-20  Tim Shen  <timshen@google.com>

	PR libstdc++/80737
	* include/std/variant(variant::variant): SFINAE on is_same first.
	* testsuite/20_util/variant/any.cc: test case.

From-SVN: r250532
2017-07-25 19:04:27 +01:00
Jonathan Wakely 3481dfbf17 PR libstdc++/80478 make std::mem_fn work with noexcept functions
PR libstdc++/80478
	* include/std/functional (_Mem_fn_traits_base): Add specializations
	for noexcept member function types.
	* testsuite/20_util/function_objects/mem_fn/80478.cc: New test.

From-SVN: r248247
2017-05-18 19:04:15 +01:00
Jonathan Wakely cf20ff6ff6 PR libstdc++/78939 make tuple_size<cv T> depend on tuple_size<T>
PR libstdc++/78939
	* include/std/utility (tuple_size<cv T>) [__cplusplus > 201402L]:
	Only define partial specializations when tuple_size<T>::value is
	valid.
	* testsuite/20_util/tuple/78939.cc: New.

From-SVN: r247978
2017-05-12 16:53:19 +01:00
Jonathan Wakely 38d68cf0f5 Fix incorrect results from std::boyer_moore_searcher
* include/std/functional (default_searcher, __boyer_moore_array_base)
	(__is_std_equal_to, __boyer_moore_base_t, boyer_moore_searcher)
	(boyer_moore_horspool_searcher): Remove redundant namespace
	qualification.
	(default_searcher::operator()): Construct return value early and
	advance second member in-place.
	(boyer_moore_horspool_searcher::operator()): Increment random access
	iterator directly instead of using std::next.
	(boyer_moore_searcher::operator()): Fix return value.
	* testsuite/20_util/function_objects/searchers.cc: Check both parts
	of return values.

From-SVN: r246964
2017-04-18 12:08:00 +01:00
Jonathan Wakely b1e282ca18 Uncomment std::reference_wrapper tests that no longer fail
* testsuite/20_util/reference_wrapper/invoke.cc: Uncomment tests
	that no longer fail.

From-SVN: r246658
2017-04-03 18:16:11 +01:00
Ville Voutilainen c1e2889a32 re PR libstdc++/79141 (std::pair<int,int> p = {}; fails to compile due to ambiguous overload)
PR libstdc++/79141
* include/bits/stl_pair.h (__nonesuch_no_braces): New.
(operator=(typename conditional<
__and_<is_copy_assignable<_T1>,
is_copy_assignable<_T2>>::value,
const pair&, const __nonesuch&>::type)): Change __nonesuch
to __nonesuch_no_braces.
(operator=(typename conditional<
__not_<__and_<is_copy_assignable<_T1>,
is_copy_assignable<_T2>>>::value,
const pair&, const __nonesuch&>::type)): Likewise.
(operator=(typename conditional<
__and_<is_move_assignable<_T1>,
is_move_assignable<_T2>>::value,
pair&&, __nonesuch&&>::type)): Likewise.
* testsuite/20_util/pair/79141.cc: New.

From-SVN: r246653
2017-04-03 19:30:58 +03:00
Ville Voutilainen e2ac6765db Implement std::is_aggregate.
* include/std/type_traits (is_aggregate, is_aggregate_v): New.
* testsuite/20_util/is_aggregate/requirements/explicit_instantiation.cc:
New.
* testsuite/20_util/is_aggregate/requirements/typedefs.cc: Likewise.
* testsuite/20_util/is_aggregate/value.cc: Likewise.

From-SVN: r246651
2017-04-03 18:57:06 +03:00
Ville Voutilainen 250f5b6cc1 Implement LWG 2900, The copy and move constructors of optional are not constexpr.
Implement LWG 2900, The copy and move constructors
of optional are not constexpr.
* include/std/optional (_Optional_payload): New.
(_Optional_base): Remove the bool parameter.
(_Optional_base<_Tp, false>): Remove.
(_Optional_base()): Adjust.
(_Optional_base(nullopt_t)): Likewise.
(_Optional_base(in_place_t, _Args&&...)): Likewise.
(_Optional_base(in_place_t, initializer_list<_Up>, _Args&&...)):
Likewise.
(_Optional_base(const _Optional_base&)): Likewise.
(_Optional_base(_Optional_base&&)): Likewise.
(operator=(const _Optional_base&)): Likewise.
(operator=(_Optional_base&&)): Likewise.
(~_Optional_base()): Remove.
(_M_is_engaged()): Adjust.
(_M_get()): Likewise.
(_M_construct(_Args&&...)): Likewise.
(_M_destruct()): Likewise.
(_M_reset()): Likewise.
(_Optional_base::_Empty_byte): Remove.
(_Optional_base::_M_empty): Remove.
(_Optional_base::_M_payload): Adjust.
* testsuite/20_util/optional/cons/value_neg.cc: Adjust.
* testsuite/20_util/optional/constexpr/cons/value.cc: Add tests.

From-SVN: r246556
2017-03-29 02:05:21 +03:00
Jonathan Wakely b1bd915843 PR libstdc++/80229 restore support for shared_ptr<function type>
PR libstdc++/80229
	* include/bits/shared_ptr_base.h
	(__shared_ptr::_M_enable_shared_from_this_with): Change parameters to
	non-const and then use remove_cv to get unqualified type.
	* testsuite/20_util/enable_shared_from_this/members/const.cc: Don't
	cast away constness on object created const.
	* testsuite/20_util/shared_ptr/cons/80229.cc: New test.

From-SVN: r246520
2017-03-28 08:35:04 +01:00
Daniel Kruegler 7f359d19d0 Implement LWG 2686, std::hash<error_condition>, for C++17
2017-03-23  Daniel Kruegler  <daniel.kruegler@gmail.com>

	Implement LWG 2686, Why is std::hash specialized for error_code,
	but not error_condition?
	* include/std/system_error (hash<error_condition>): Define for C++17.
	* testsuite/20_util/hash/operators/size_t.cc (hash<error_condition>):
	Instantiate test for error_condition.
	* testsuite/20_util/hash/requirements/explicit_instantiation.cc
	(hash<error_condition>): Instantiate hash<error_condition>.

From-SVN: r246424
2017-03-23 19:40:16 +00:00
Daniel Kruegler 288695f7a4 Implement P0607R0 "Inline Variables for Standard Library" for C++17
2017-03-23  Daniel Kruegler  <daniel.kruegler@gmail.com>

	* include/bits/c++config (_GLIBCXX17_INLINE): Define.
	* include/bits/regex_constants.h (All std::regex_constants constants):
	Add _GLIBCXX17_INLINE as per P0607R0.
	* include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock):
	Likewise.
	* include/bits/stl_pair.h (piecewise_construct): Likewise.
	* include/bits/uses_allocator.h (allocator_arg, uses_allocator_v)
	(__is_uses_allocator_constructible_v)
	(__is_nothrow_uses_allocator_constructible_v): Likewise.
	* include/std/chrono (treat_as_floating_point_v): Likewise.
	* include/std/functional (is_bind_expression_v, is_placeholder_v):
	Likewise.
	* include/std/optional (nullopt): Likewise.
	* include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v)
	ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise.
	* include/std/system_error (is_error_code_enum_v)
	(is_error_condition_enum_v): Likewise.
	* include/std/tuple (tuple_size_v, ignore): Likewise.
	(ignore): Declare ignore constexpr as per LWG 2773, declare assignment
	constexpr as per LWG 2933.
	* include/std/type_traits (All variable templates): Add
	_GLIBCXX17_INLINE as per P0607R0.
	* include/std/variant (variant_size_v, variant_npos, __index_of_v)
	(__tuple_count_v, __exactly_once): Likewise.
	* testsuite/18_support/headers/new/synopsis.cc
	(hardware_destructive_interference_size)
	(hardware_constructive_interference_size): Likewise for commented-out
	variables.
	* testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new
	test function for constexpr std::ignore (LWG 2773).
	* testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New
	test for LWG 2933.

From-SVN: r246423
2017-03-23 19:40:07 +00:00
Jonathan Wakely af181c91a9 Add deduction guides for C++17 (P0433R2, partial)
* include/bits/shared_ptr.h (shared_ptr, weak_ptr): Add deduction
	guides for C++17.
	* include/bits/std_function.h (function): Likewise.
	* include/bits/stl_pair.h (pair): Likewise.
	* include/debug/array (__gnu_debug::array): Likewise.
	* include/std/array (array): Likewise.
	* include/std/functional (make_default_searcher)
	(make_boyer_moore_searcher, make_boyer_moore_horspool_searcher):
	Remove generator functions.
	* include/std/tuple (tuple): Add deduction guides.
	* include/std/valarray (valarray): Likewise.
	* testsuite/20_util/function_objects/searchers.cc: Adjust to use
	class template argument deduction instead of generator functions.
	* testsuite/20_util/function/cons/deduction.cc: New test.
	* testsuite/20_util/optional/cons/deduction_guide.cc: Rename to ...
	* testsuite/20_util/optional/cons/deduction.cc: ... here.
	* testsuite/20_util/pair/cons/deduction.cc: New test.
	* testsuite/20_util/shared_ptr/cons/deduction.cc: New test.
	* testsuite/20_util/tuple/cons/deduction.cc: New test.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust dg-error.
	* testsuite/20_util/unique_ptr/cons/deduction_neg.cc: New test.
	* testsuite/20_util/weak_ptr/cons/deduction.cc: New test.
	* testsuite/23_containers/array/cons/deduction.cc: New test.
	* testsuite/23_containers/array/cons/deduction_neg.cc: New test.
	* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc:
	Adjust dg-error.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc: Likewise.
	* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
	Likewise.
	* testsuite/26_numerics/valarray/deduction.cc: New test.
	* testsuite/30_threads/lock_guard/cons/deduction.cc: New test.
	* testsuite/30_threads/scoped_lock/cons/deduction.cc: New test.
	* testsuite/30_threads/unique_lock/cons/deduction.cc: New test.

From-SVN: r246389
2017-03-22 15:58:35 +00:00
Ville Voutilainen df99018275 Implement LWG 2857, {variant,optional,any}::emplace should return the constructed value.
Implement LWG 2857, {variant,optional,any}::emplace should
return the constructed value.
* include/std/any (emplace(_Args&&...)): Change the return type and
return a reference to the constructed value.
(emplace(initializer_list<_Up>, _Args&&...)): Likewise.
* include/std/optional (emplace(_Args&&...)): Likewise.
(emplace(initializer_list<_Up>, _Args&&...)): Likewise.
* include/std/variant (emplace<_Tp>(_Args&&...)): Likewise.
(emplace<_Tp>(initializer_list<_Up>, _Args&&...)): Likewise.
(emplace<_Np>(_Args&&...)): Likewise.
(emplace<_Np>(initializer_list<_Up>, _Args&&...)): Likewise.
* testsuite/20_util/any/assign/emplace.cc: Add tests for
checking the return value of emplace.
* testsuite/20_util/any/misc/any_cast_neg.cc: Adjust.
* testsuite/20_util/optional/assignment/6.cc: Add tests for
checking the return value of emplace.
* testsuite/20_util/variant/run.cc: Likewise.

From-SVN: r246182
2017-03-16 01:13:20 +02:00
Ville Voutilainen fd231ad75a Implement LWG 2806, Base class of bad_optional_access.
* include/std/optional (bad_optional_access):
Derive from std::exception.
(bad_optional_access::bad_optional_access): Adjust.
(bad_optional_access::what): New.
(__throw_bad_optional_access(const char*)):
Remove the parameter and adjust calls.
* testsuite/20_util/optional/cons/value_neg.cc: Adjust.
* testsuite/20_util/optional/typedefs.cc: Likewise.

From-SVN: r246103
2017-03-13 20:03:30 +02:00
Ville Voutilainen 06272afbd3 Implement LWG 2934, optional<const T> doesn't compare with T.
* include/std/optional
(operator==(const optional<_Tp>&, const optional<_Tp>&)):
Turn into operator==(const optional<_Tp>&, const optional<_Up>&).
(operator!=(const optional<_Tp>&, const optional<_Tp>&)):
Turn into operator!=(const optional<_Tp>&, const optional<_Up>&).
(operator<(const optional<_Tp>&, const optional<_Tp>&)):
Turn into operator<(const optional<_Tp>&, const optional<_Up>&.
(operator>(const optional<_Tp>&, const optional<_Tp>&)):
Turn into operator>(const optional<_Tp>&, const optional<_Up>&.
(operator<=(const optional<_Tp>&, const optional<_Tp>&)):
Turn into operator<=(const optional<_Tp>&, const optional<_Up>&).
(operator>=(const optional<_Tp>&, const optional<_Tp>&)):
Turn into operator>=(const optional<_Tp>&, const optional<_Up>&).
(operator==(const optional<_Tp>&, const _Tp&)):
Turn into operator==(const optional<_Tp>&, const _Up&).
(operator==(const _Tp&, const optional<_Tp>&)):
Turn into operator==(const _Up&, const optional<_Tp>&).
(operator!=(const optional<_Tp>&, const _Tp&)):
Turn into operator!=(const optional<_Tp>&, const _Up&).
(operator!=(const _Tp&, const optional<_Tp>&)):
Turn into operator!=(const _Up&, const optional<_Tp>&).
(operator<(const optional<_Tp>&, const _Tp&)):
Turn into operator<(const optional<_Tp>&, const _Up&).
(operator<(const _Tp&, const optional<_Tp>&)):
Turn into operator<(const _Up&, const optional<_Tp>&).
(operator>(const optional<_Tp>&, const _Tp&)):
Turn into operator>(const optional<_Tp>&, const _Up&).
(operator>(const _Tp&, const optional<_Tp>&)):
Turn into operator>(const _Up&, const optional<_Tp>&).
(operator<=(const optional<_Tp>&, const _Tp&)):
Turn into operator<=(const optional<_Tp>&, const _Up&).
(operator<=(const _Tp&, const optional<_Tp>&)):
Turn into operator<=(const _Up&, const optional<_Tp>&).
(operator>=(const optional<_Tp>&, const _Tp&)):
Turn into operator>=(const optional<_Tp>&, const _Up&).
(operator>=(const _Tp&, const optional<_Tp>&)):
Turn into operator>=(const _Up&, const optional<_Tp>&).
* testsuite/20_util/optional/relops/7.cc: New.

From-SVN: r246076
2017-03-12 12:32:31 +02:00
Jonathan Wakely 7dcc645ccd P0604R0 add invoke_result, is_invocable etc. for C++17
* include/bits/invoke.h (__invoke): Use __invoke_result instead of
	result_of, and __is_nothrow_invocable instead of
	__is_nothrow_callable.
	* include/bits/shared_ptr_base.h (__shared_ptr): Use __is_invocable
	instead of __is_callable.
	* include/std/functional (invoke): use invoke_result_t instead of
	result_of_t and is_nothrow_invocable instead of is_nothrow_callable.
	(_Not_fn): Use __invoke_result instead of result_of.
	* include/std/type_traits (__result_of_memobj, __result_of_memfun):
	Remove partial specializations for reference_wrapper types.
	(__result_of_impl): Use __inv_unwrap to strip reference_wrapper.
	(__invoke_result): Define replacement for result_of and then use it to
	define result_of.
	(__is_callable_impl, __is_callable, __is_nothrow_callable): Replace
	with __is_invocable_impl, __is_invocable, and __is_nothrow_invocable
	respectively.
	(invoke_result, invoke_result_t): Define for C++17.
	(is_callable, is_nothrow_callable): Replace with is_invocable,
	is_invocable_r, is_nothrow_invocable, and is_nothrow_invocable_r.
	(is_callable_v, is_nothrow_callable_v): Replace with is_invocable_v,
	is_invocable_r_v, is_nothrow_invocable_v, and is_nothrow_invocable_r_v.
	* include/std/variant (hash<variant<T...>>): Use is_nothrow_invocable_v
	instead of is_nothrow_callable_v.
	* testsuite/20_util/function_objects/invoke/59768.cc: Remove unused
	main function.
	* testsuite/20_util/function_objects/not_fn/1.cc: Use is_invocable
	instead of is_callable.
	* testsuite/20_util/is_callable/*: Rename directory and adjust tests
	to use new traits.
	* testsuite/20_util/is_notjrow_callable/*: Likewise.
	* testsuite/20_util/optional/hash.cc: Use is_invocable_v instead of
	is_callable.
	* testsuite/20_util/variant/hash.cc: Likewise.

From-SVN: r246036
2017-03-10 15:29:38 +00:00
Jonathan Wakely 5782e30941 PR 79798 Fix incorrect use of std::result_of in std::bind
PR libstdc++/79798
	* include/std/functional (bind::_Res_type_impl): Fix incorrect use of
	result_of that loses top-level cv-qualifiers.
	* testsuite/20_util/bind/79798.cc: New test.

From-SVN: r245827
2017-03-02 03:43:36 +00:00
Dinka Ranns 1dee318ad8 C++17 GB50 resolution (P0505R0)
2017-02-19  Dinka Ranns  <dinka.ranns@googlemail.com>

	C++17 GB50 resolution
	* include/std/chrono (duration::operator++()): Add
	_GLIBCXX17_CONSTEXPR.
	(duration::operator++(int)): Likewise.
	(duration::operator--()): Likewise.
	(duration::operator--(int)): Likewise.
	(duration::operator+=(const duration&)): Likewise.
	(duration::operator-=(const duration&)): Likewise.
	(duration::operator*=(const rep&)): Likewise.
	(duration::operator/=(const rep&)): Likewise.
	(duration::operator%=(const rep&)): Likewise.
	(duration::operator%=(const duration&)): Likewise.
	(time_point::operator+=(const duration&)): Likewise.
	(time_point::operator-=(const duration&)): Likewise.
	* testsuite/20_util/duration/arithmetic/constexpr_c++17.cc: New test.
	* testsuite/20_util/duration/literals/range.cc: Adjust dg-error.
	* testsuite/20_util/time_point/arithmetic/constexpr.cc: New test.

From-SVN: r245575
2017-02-19 16:04:35 +00:00
Tim Shen d255829bbc re PR libstdc++/78723 ([variant] P0393r3: "Making variant greater equal again" is unimplemented)
PR libstdc++/78723
	* include/std/variant (operator<(), operator>(), operator<=(),
	operator>=(), operator==(), operator!=()): Implement P0393R3.
	* testsuite/20_util/variant/compile.cc: Adjust tests.
	* testsuite/20_util/variant/run.cc: Adjust tests.

From-SVN: r245475
2017-02-15 09:01:06 +00:00
Tim Shen 7d5abe42c2 re PR libstdc++/79513 (std::visit doesn't handle references)
PR libstdc++/79513
	* include/std/variant (visit()): Forward variant types to the return
	type detection code.
	* testsuite/20_util/variant/compile.cc: Add test cases.

From-SVN: r245474
2017-02-15 07:38:20 +00:00
Jonathan Wakely 99ebfe9075 PR libstdc++/79467 use lvalues in is_callable check
PR libstdc++/79467
	* include/bits/shared_ptr_base.h (__shared_ptr(_Yp*, _Deleter))
	(__shared_ptr(_Yp*, _Deleter, _Alloc)): Use lvalue types in
	__is_callable check.
	* testsuite/20_util/shared_ptr/cons/79467.cc: New.

From-SVN: r245363
2017-02-11 21:08:11 +00:00
Jonathan Wakely 3e4fd831e9 Fix test failure at -O0 by pruning output
PR libstdc++/79323
	* testsuite/20_util/duration/literals/range.cc: Prune extra output
	at -O0.

From-SVN: r245211
2017-02-06 16:39:56 +00:00
Ville Voutilainen 1dd9523917 Implement LWG 2825, LWG 2756 breaks class template argument deduction for optional.
* include/std/optional: Add a deduction guide.
* testsuite/20_util/optional/cons/deduction_guide.cc: New.

From-SVN: r245024
2017-01-30 15:37:16 +02:00
Jakub Jelinek 68edb9bafe update-copyright.py: Add libhsail-rt to self.default_dirs and call self.add_dir on it.
contrib/
	* update-copyright.py: Add libhsail-rt to self.default_dirs
	and call self.add_dir on it.  Add Intel Corporation to external
	authors.
gcc/
	* brig-builtins.def: Update copyright years.
	* config/arm/arm_acle_builtins.def: Update copyright years.
gcc/brig/
	Update copyright years.
gcc/testsuite/
	* brig.dg/dg.exp: Update copyright years.
	* lib/brig-dg.exp: Update copyright years.
	* lib/brig.exp: Update copyright years.
libhsail-rt/
	Update copyright years.
libstdc++-v3/
	* libsupc++/eh_atomics.h: Update copyright years.
	* testsuite/20_util/unique_ptr/cons/default.cc: Update copyright years.

From-SVN: r244919
2017-01-26 09:24:22 +01:00
Ville Voutilainen 509912a611 Make poisoned hashes SFINAE away the call operator of the hash.
* include/bits/functional_hash.h
(__poison_hash::__enable_hash_call): New.
* include/std/optional (__optional_hash_call_base): New.
(hash<optional<_Tp>>): Derive from the new base,
move the hash function into that base.
* include/std/variant (__variant_hash_call_base_impl): New.
(__variant_hash_call_base): Likewise.
(hash<variant<_Types...>>): Derive from the new base,
move the hash function into that base.
* testsuite/20_util/optional/hash.cc: Add tests for is_callable.
* testsuite/20_util/variant/hash.cc: Likewise.

From-SVN: r244748
2017-01-21 17:38:23 +02:00
Jonathan Wakely 4dfdda108f PR72792 detect allocator pointer types without invalid rebinding
PR libstdc++/72792
	* include/bits/alloc_traits.h (__allocator_traits_base::__diff_type)
	(__allocator_traits_base::__size_type): Remove.
	(allocator_traits::_Ptr): New class template to detect const and void
	pointer types without instantiating pointer_traits::rebind
	unnecessarily.
	(allocator_traits::_Diff): Likewise for detecting difference_type.
	(allocator_traits::_Size): New class template to detect size_type
	without instantiating make_unsigned unnecessarily.
	* include/bits/ptr_traits.h (pointer_traits::element_type): Use
	__detected_or_t instead of __detected_or_t_.
	* include/std/type_traits (__detected_or_t_): Remove.
	* testsuite/20_util/allocator_traits/members/pointers.cc: New test.

From-SVN: r244706
2017-01-20 12:03:36 +00:00
Jonathan Wakely a3a1620bb8 PR72792 PR72793 relax requirements on rebind members
PR libstdc++/72792
	PR libstdc++/72793
	* include/bits/alloc_traits.h (__allocator_traits_base::__rebind):
	Replace with class template using void_t.
	(__alloc_rebind): Define in terms of
	__allocator_traits_base::__rebind.
	(allocator_traits): Remove unconditional static_assert for
	rebind_alloc.
	* include/bits/ptr_traits.h (__replace_first_arg): Remove type member.
	(pointer_traits::__rebind): Replace with class template using void_t.
	(pointer_traits::rebind): Define in terms of __rebind.
	(pointer_traits): Remove unconditional static_assert for rebind.
	* testsuite/20_util/allocator_traits/members/rebind_alloc.cc: New test.
	* testsuite/20_util/pointer_traits/rebind.cc: New test.

From-SVN: r244680
2017-01-20 02:36:16 +00:00
Jonathan Wakely 38a9e5a6c0 PR69321 fix any_cast<T>(any*) for non-copyable T
PR libstdc++/69321
	* include/experimental/any (__any_caster): Avoid instantiating
	manager function for types that can't be stored in any.
	* include/std/any (__any_caster): Likewise.
	* testsuite/20_util/any/misc/any_cast.cc: Test non-copyable type.
	* testsuite/experimental/any/misc/any_cast.cc: Likewise.

From-SVN: r244678
2017-01-20 01:22:54 +00:00
Jonathan Wakely c6ab906191 PR78361 recognise noexcept functions as referenceable
2017-01-13  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/78361
	* testsuite/20_util/add_pointer/value.cc: Test forming function
	pointers.

2017-01-13  Michael Brune  <lucdanton@free.fr>

	PR libstdc++/78361
	* include/std/type_traits (__is_referenceable): Handle noexcept
	function types.

From-SVN: r244432
2017-01-13 12:18:42 +00:00
Jonathan Wakely 4704f28e7a PR66284 remove std::function special case for reference_wrapper
PR libstdc++/66284
	* doc/xml/manual/intro.xml: Document LWG 2781 change.
	* doc/html/*: Regenerate.
	* include/std/functional (_Function_base::_Ref_manager): Remove.
	(_Function_handler): Remove partial specializations for
	reference_wrapper.
	(function::target): Remove special case for const qualification.
	* testsuite/20_util/function/6.cc: Adjust tests for target type.
	* testsuite/20_util/function/7.cc: Likewise.
	* testsuite/20_util/function/8.cc: Likewise.

From-SVN: r244364
2017-01-12 14:28:38 +00:00
Ville Voutilainen f3df0b3cde Reduce the size of variant, it doesn't need an index of type size_t internally.
Reduce the size of variant, it doesn't need an index of
type size_t internally.
* include/std/variant (parse_numbers.h): New include.
(__select_index): New.
(_Variant_storage<false, _Types...>::_M_reset_impl): Use
_index_type for comparison with variant_npos.
(_Variant_storage<false, _Types...>::__index_type): New.
(_Variant_storage<false, _Types...>::_M_index): Change the
type from size_t to __index_type.
(_Variant_storage<true, _Types...>::__index_type): New.
(_Variant_storage<true, _Types...>::_M_index): Change the
type from size_t to __index_type.
(_Variant_base::_M_valid): Use _Storage::__index_type
for comparison with variant_npos.
(variant::index): Use _Base::_Storage::__index_type
for comparison with variant_npos.
* testsuite/20_util/variant/index_type.cc: New.

From-SVN: r244309
2017-01-11 13:23:43 +02:00
Ville Voutilainen 1308676957 Implement 2801, Default-constructibility of unique_ptr.
* include/bits/unique_ptr.h (__uniq_ptr_impl::_DeleterConstraint): New.
(unique_ptr::_DeleterConstraint): Likewise.
(unique_ptr()): Constrain.
(unique_ptr(pointer)): Likewise.
(unique_ptr(nullptr_t)): Likewise.
(unique_ptr<_Tp[], _Dp>::_DeleterConstraint): New.
(unique_ptr<_Tp[], _Dp>::unique_ptr()): Constrain.
(unique_ptr<_Tp[], _Dp>::unique_ptr(_Up)): Likewise.
(unique_ptr<_Tp[], _Dp>::unique_ptr(nullptr_t)): Likewise.
* testsuite/20_util/unique_ptr/assign/48635_neg.cc: Adjust.
* testsuite/20_util/unique_ptr/cons/cv_qual_neg.cc: Likewise.
* testsuite/20_util/unique_ptr/cons/default.cc: New.
* testsuite/20_util/unique_ptr/cons/ptr_deleter_neg.cc: Adjust.

From-SVN: r244054
2017-01-04 15:21:02 +02:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Ville Voutilainen 2ae2d394c1 Implement LWG 2842, in_place_t check for optional::optional(U&&) should decay U.
Implement LWG 2842, in_place_t check for optional::optional(U&&)
should decay U.
* include/std/optional (_Optional_base(in_place_t, _Args&&...)):
Constrain.
(_Optional_base(in_place_t, initializer_list<_Up>, _Args&&...)):
Turn the int-pack constraint hack into a saner bool.
(_Optional_base<_Tp, false>::_Optional_base(in_place_t, _Args&&...)):
Constrain.
(_Optional_base<_Tp, false>::_Optional_base(in_place_t,
initializer_list<_Up>, _Args&&...)):
Turn the int-pack constraint hack into a saner bool.
(optional(_Up&&)): Constrain against in_place_t.
(optional(in_place_t, _Args&&...)): Constrain.
(constexpr optional(in_place_t, initializer_list<_Up>, _Args&&...)):
Turn the int-pack constraint hack into a saner bool.
* testsuite/20_util/optional/cons/value_neg.cc: Add a test for
a type that is constructible from in_place.

From-SVN: r243966
2016-12-29 21:19:59 +02:00
Ville Voutilainen 4b21c3ea03 Make the perfect-forwarding constructor of a two-element tuple sfinae away when the first argument is an allocator_arg.
Make the perfect-forwarding constructor of a two-element tuple
sfinae away when the first argument is an allocator_arg.
* include/std/tuple (tuple(_U1&&, _U2&&)): Constrain.
* testsuite/20_util/tuple/cons/allocator_with_any.cc: New.
* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust.

From-SVN: r243795
2016-12-19 14:55:33 +02:00
Ville Voutilainen 6254952346 Implement LWG 2769, Redundant const in the return type of any_cast(const any&).
Implement LWG 2769, Redundant const in the return type of
any_cast(const any&).
* include/std/any (_AnyCast): New.
(any_cast(const any&)): Use it and add an explicit cast for return.
(any_cast(any&)): Likewise.
(any_cast(any&&)): Likewise.
* testsuite/20_util/any/misc/any_cast.cc: Add a test for a type
that has an explicit copy constructor.
*testsuite/20_util/any/misc/any_cast_neg.cc: Adjust.

From-SVN: r243739
2016-12-16 13:34:45 +02:00
Jonathan Wakely 1f153a1d2a Replace dynamic exception specifications in testsuite
* testsuite/util/testsuite_hooks.h (THROW): Define.
	* testsuite/util/replacement_memory_operators.h: Include
	testsuite_hooks.h and use THROW macro.
	* testsuite/util/testsuite_tr1.h: Likewise.
	* testsuite/20_util/allocator/1.cc: Use THROW macro.
	* testsuite/22_locale/locale/cons/12352.cc: Likewise.
	* testsuite/23_containers/vector/zero_sized_allocations.cc: Likewise.
	* testsuite/30_threads/lock_guard/cons/1.cc: Replace dynamic exception
	specification with noexcept-specifier.
	* testsuite/ext/pool_allocator/allocate_chunk.cc: Include
	testsuite_hooks.h and use THROW macro.
	* testsuite/ext/profile/replace_new.cc: Likewise.

From-SVN: r243353
2016-12-07 15:22:51 +00:00