Commit Graph

132 Commits

Author SHA1 Message Date
Jonathan Wakely e737fc0cba PR libstdc++/82685 add 'noexcept' to string_view literals
Backport from mainline
2017-10-24  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/82685
	* include/experimental/string_view (operator""sv): Add noexcept.
	* include/std/string_view (operator""sv): Likewise.

From-SVN: r255325
2017-12-01 17:12:07 +00:00
Jonathan Wakely 24aeb1b939 Fix path::iterator post-increment and post-decrement
Backport from mainline
2017-10-19  Jonathan Wakely  <jwakely@redhat.com>

	* include/experimental/bits/fs_path.h (path::iterator++(int))
	(path::iterator--(int)): Fix for paths with only one component.
	* testsuite/experimental/filesystem/path/itr/traversal.cc: Test
	post-increment and post-decrement.

From-SVN: r253942
2017-10-20 16:14:23 +01:00
Jonathan Wakely e38bde5423 PR libstdc++/70483 make std::experimental::string_view fully constexpr
Backport from mainline
2017-09-12  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/70483
	* include/experimental/bits/string_view.tcc (basic_string_view::find)
	(basic_string_view::rfind, basic_string_view::find_first_of)
	(basic_string_view::find_last_of, basic_string_view::find_first_not_of)
	(basic_string_view::find_last_not_of): Add constexpr specifier.
	* include/experimental/string_view (basic_string_view::remove_prefix)
	(basic_string_view::remove_suffix, basic_string_view::swap)
	(basic_string_view::compare, basic_string_view::find)
	(basic_string_view::rfind, basic_string_view::find_first_of)
	(basic_string_view::find_last_of, basic_string_view::find_first_not_of)
	(basic_string_view::find_last_not_of, operator==, operator!=)
	(operator<, operator>, operator<=, operator>=): Likewise.
	* testsuite/experimental/string_view/operations/compare/char/70483.cc:
	New.

From-SVN: r252032
2017-09-12 17:27:14 +01:00
Jonathan Wakely 0182e8bb7b Implement std::experimental::source_location (N4519)
Backport from mainline
2017-05-16  Jonathan Wakely  <jwakely@redhat.com>

	* configure: Regenerate.
	* doc/xml/manual/status_cxx2017.xml: Update status table.
	* doc/html/*: Regenerate.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/experimental/source_location: New header implementing N4519.
	* testsuite/experimental/source_location/1.cc: New test.

From-SVN: r250538
2017-07-25 19:05:07 +01:00
Jonathan Wakely 6c018e95a4 Prevent __uses_alloc from holding dangling references
Backport from mainline
2017-07-06  Jonathan Wakely  <jwakely@redhat.com>

	* include/bits/uses_allocator.h (__use_alloc(const _Alloc&&)): Add
	deleted overload to prevent dangling references to rvalues.
	* include/experimental/memory_resource
	(polymorphic_allocator::construct): Do not call __use_alloc with
	rvalue arguments.

From-SVN: r250537
2017-07-25 19:04:59 +01:00
Jonathan Wakely 6cff9199c1 PR libstdc++/80448 remove noexcept from defaulted functions
PR libstdc++/80448
	* include/experimental/bits/fs_dir.h (directory_iterator)
	(recursive_directory_iterator): Remove noexcept from defaulted
	constructors.

From-SVN: r246993
2017-04-19 12:03:43 +01:00
Jonathan Wakely cb701078b1 Ensure <experimental/iterator> includes <iterator>
* include/experimental/iterator: Include <iterator>.
	* testsuite/experimental/iterator/requirements.cc: Check for contents
	of <iterator>.

From-SVN: r245686
2017-02-23 18:25:22 +00:00
Jonathan Wakely 3e5fb20f1f Fix namespace versioning and remove __detail::__identity helpers
PR libstdc++/79243
	* include/bits/c++config (literals::string_view_literals::__7): Add.
	Only declare versioned namespaces for the relevant C++ dialects.
	* include/experimental/bits/erase_if.h (fundamentals_v2::__detail):
	Add versioning macros.
	* include/experimental/bits/lfts_config.h:
	(fundamentals_v1::__detail::__7, fundamentals_v2::__detail::__7): Add.
	* include/experimental/string_view (fundamentals_v2::__detail):
	Add versioning macros.
	(fundamentals_v2::__detail::__identity): Remove.
	(fundamentals_v2::__detail::__idt): Use common_type instead of
	__detail::__identity.
	* include/std/string_view (__detail::__identity, __detail::__idt):
	Likewise.
	(literals::string_view_literals): Fix nesting of versioning macros.

From-SVN: r244945
2017-01-26 18:32:55 +00:00
Jonathan Wakely 8cb7179d24 PR libstdc++/79206 check string_view sizes in operator==
PR libstdc++/79206
	* include/experimental/string_view (operator==): Check sizes first.
	* include/std/string_view (operator==): Likewise.

From-SVN: r244865
2017-01-24 12:00:47 +00:00
Jonathan Wakely 61ad58f3aa PR libstdc++/79195 fix make_array type deduction
PR libstdc++/79195
	* include/experimental/array (__make_array_elem): New class template
	and partial specialization.
	(__is_reference_wrapper): Move into __make_array_elem specialization.
	(make_array): Use __make_array_elem to determine element type and move
	static assertion into specialization. Qualify std::forward call.
	(to_array): Add exception specifiation.
	* testsuite/experimental/array/make_array.cc: Test argument types
	without a common type.
	* testsuite/experimental/array/neg.cc: Adjust expected error message.

From-SVN: r244813
2017-01-23 15:56:05 +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 2ae27b7076 PR69301 don't assume atomic<T> can default construct T
PR libstdc++/69301
	* include/std/atomic (atomic<T>::load, atomic<T>::exchange): Use
	aligned buffer instead of default-initialized variable.
	* testsuite/29_atomics/atomic/69301.cc: New test.
	* include/experimental/memory (observer_ptr::release): Use reserved
	name.
	* include/ext/pointer.h (_Pointer_adapter::operator++(int))
	(_Pointer_adapter::operator--(int)): Likewise.

From-SVN: r244588
2017-01-18 18:36:45 +00:00
Jonathan Wakely b08fdbb845 PR68925 don't use thread_local static for stateless object
PR libstdc++/68925
	* include/experimental/random (randint): Use temporary instead of
	thread_local static.

From-SVN: r244584
2017-01-18 17:18:47 +00:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Jonathan Wakely 435f434288 Replace uses of C++14 remove_cv_t alias in C++11 header
* include/experimental/bits/fs_path.h (path::_S_convert): Replace
	uses of C++14 std::remove_cv_t alias template.

From-SVN: r243355
2016-12-07 15:23:01 +00:00
Ville Voutilainen 1637d42545 Constrain optional's __constexpr_addressof in its return type and use a constexpr addressof for optional, if available.
Constrain optional's __constexpr_addressof in its return type
and use a constexpr addressof for optional, if available.
* include/experimental/optional (__constexpr_addressof):
Constrain in the return type instead of in a template parameter.
(_Has_addressof_mem)
(_Has_addressof_free, _Has_addressof, __constexpr_addressof):
Guard with #ifndef __cpp_lib_addressof_constexpr.
(operator->()): Use std::__addressof if it's constexpr.

From-SVN: r243298
2016-12-06 14:47:54 +02:00
Felix Morgner f6cdfe8264 PR78494 add missing returns to propagate_const
2016-11-23  Felix Morgner  <felix.morgner@gmail.com>
	    Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/78494
	* include/experimental/propagate_const (propagate_const::operator=):
	Add missing return statements.
	* testsuite/experimental/propagate_const/assignment/move_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/experimental/propagate_const/requirements2.cc: Likewise.

Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>

From-SVN: r242760
2016-11-23 14:45:29 +00:00
Jonathan Wakely 881ca4c9de PR78326 fix incorrect access of data member in base class
PR libstdc++/78326
	* include/experimental/memory_resource (memory_resource::_S_max_align):
	Change access to protected.

From-SVN: r242373
2016-11-14 02:00:26 +00:00
Jonathan Wakely b2343559f2 Add array support to std::shared_ptr for C++17
* doc/xml/manual/status_cxx2017.xml: Update status.
	* doc/html/manual/status.html: Regenerate.
	* include/bits/shared_ptr.h (shared_ptr(unique_ptr<_Yp, _Del>)): Add
	extension constructor to maintain C++14 behaviour.
	* include/bits/shared_ptr_base.h (__sp_array_delete): Add new struct.
	(__shared_count(_Ptr, false_type), __shared_count(_Ptr, true_type)):
	New constructors.
	(__sp_compatible_with, __sp_is_constructible): Add specializations
	for array support.
	(__sp_is_constructible_arr, __sp_is_constructible_arrN): New helpers.
	(__shared_ptr_access): New base class for observer member functions.
	(__shared_ptr::element_type): Use remove_extent.
	(__shared_ptr::_UniqCompatible): Add __sp_compatible_with check.
	(__shared_ptr(_Yp*)): Use tag dispatching to call new __shared_count
	constructor.
	(__shared_ptr(unique_ptr<_Yp, _Del>)): Add extension constructor.
	(__shared_ptr::operator*, __shared_ptr::operator->): Remove and
	inherit from __shared_ptr_access base class.
	(__shared_ptr::__has_esft_base): Return false for array types.
	(__weak_ptr::element_type): Use remove_extent.
	* include/experimental/bits/shared_ptr.h (__libfund_v1): Remove.
	(__shared_ptr<__libfund_v1<_Tp>>): Remove specializations.
	(__wak_ptr<__libfund_v1<_Tp>>): Likewise.
	(experimental::__sp_compatible_v): Redefine using
	__sp_compatible_with.
	(experimental::__sp_is_constructible_v): Redefine using
	__sp_is_constructible.
	(get_deleter, operator<<): Change argument from __shared_ptr to
	shared_ptr.
	* testsuite/20_util/shared_ptr/cons/array.cc: New test.
	* testsuite/20_util/shared_ptr/cons/unique_ptr_array.cc: Adjust for
	new behaviour.
	* testsuite/20_util/shared_ptr/observers/array.cc: Test observers for
	arrays.
	* testsuite/20_util/shared_ptr/observers/array_neg.cc: New test.

From-SVN: r242369
2016-11-13 22:57:45 +00:00
Jonathan Wakely f0414b973f Make filesystem::path work with basic_string_view (P0392R0)
* include/experimental/bits/fs_path.h (__is_path_src)
	(_S_range_begin, _S_range_end): Overload to treat string_view as a
	Source object.
	(path::operator+=, path::compare): Overload for basic_string_view.
	* testsuite/experimental/filesystem/path/construct/string_view.cc:
	New test.
	* testsuite/experimental/filesystem/path/construct/
	string_view_cxx17.cc: New test.

From-SVN: r241658
2016-10-28 19:48:43 +01:00
Jonathan Wakely fcfceb1afb Fix filesystem::path for iterators with const value_type
* include/experimental/bits/fs_path.h
	(path::_S_convert<_Iter>(_Iter, _Iter)): Remove cv-qualifiers from
	iterator's value_type.
	(path::_S_convert<_Iter>(_Iter __first, __null_terminated)): Likewise.
	Do not use operation not supported by input iterators.
	(path::__is_path_iter_src): Add partial specialization for const
	encoded character types.
	* testsuite/experimental/filesystem/path/construct/range.cc: Test
	construction from input iterators with const value types.

From-SVN: r241654
2016-10-28 18:47:57 +01:00
Jonathan Wakely ec0b1056a7 Add recursive_directory_iterator::pop(error_code&)
* include/experimental/bits/fs_dir.h (recursive_directory_iterator):
	Overload pop (LWG 2706).
	* src/filesystem/dir.cc (recursive_directory_iterator::pop): Define
	new overload.
	* testsuite/experimental/filesystem/iterators/pop.cc: New test.

From-SVN: r241559
2016-10-26 16:20:04 +01:00
Ville Voutilainen a3f6007cbc Cross-port exception-safety and move fixes of std::any to std::experimental::any.
Cross-port exception-safety and move fixes of std::any to
std::experimental::any.
* include/experimental/any (operator=(const any&)):
Make strongly exception-safe.
(operator=(any&&)): clear() unconditionally in the case where
rhs has a value.
(_Manager_internal<_Tp>::_S_manage): Move in _Op_xfer, don't copy.
* testsuite/experimental/any/assign/2.cc: Adjust.
* testsuite/experimental/any/assign/exception.cc: New.
* testsuite/experimental/any/cons/2.cc: Adjust.
* testsuite/experimental/any/misc/any_cast_neg.cc: Ajust.

From-SVN: r241479
2016-10-24 16:22:11 +03:00
Ville Voutilainen f11cc05023 Cross-port the latest resolution of LWG2756 and some bug-fixes to experimental::optional.
Cross-port the latest resolution of LWG2756 and some
bug-fixes to experimental::optional.
PR libstdc++/77288
PR libstdc++/77727
* include/experimental/optional (_Optional_base):
Remove constructors that take a _Tp.
(__is_optional_impl, __is_optional): Remove.
(__converts_from_optional): New.
(optional(_Up&&)): Fix constraints, call base with in_place.
(optional(const optional<_Up>&)): Fix constraints, use emplace.
(optional(optional<_Up>&&)): Likewise.
(operator=(_Up&&)): Fix constraints.
(operator=(const optional<_Up>&)): Likewise.
(operator=(optional<_Up>&&)): Likewise.
(emplace(_Args&&...)): Constrain.
(emplace(initializer_list<_Up>, _Args&&...)): Likewise.
* testsuite/experimental/optional/77288.cc: New.
* testsuite/experimental/optional/assignment/5.cc: Adjust.
* testsuite/experimental/optional/cons/77727.cc: New.
* testsuite/experimental/optional/cons/value.cc: Adjust.

From-SVN: r241476
2016-10-24 15:46:44 +03:00
Jonathan Wakely d17f7088fb LWG2720 implement filesystem::perms::symlink_nofollow
* include/experimental/bits/fs_fwd.h (perms::resolve_symlinks):
	Replace with symlink_nofollow (LWG 2720).
	* src/filesystem/ops.cc (permissions(const path&, perms, error_code&)):
	Handle symlink_nofollow.
	* testsuite/experimental/filesystem/operations/create_symlink.cc: New
	test.
	* testsuite/experimental/filesystem/operations/permissions.cc: Test
	overload taking error_code.

From-SVN: r241418
2016-10-21 18:01:05 +01:00
Jonathan Wakely 2be9212713 LWG2725 Fix error reporting for filesystem::exists
* include/experimental/bits/fs_ops.h
	(exists(const path&, error_code&)): Clear error if status is known
	(LWG 2725).
	(status(const path&, error_code&)): Handle EOVERFLOW.
	* testsuite/experimental/filesystem/operations/exists.cc: Test
	overload taking an error_code.

From-SVN: r241417
2016-10-21 18:00:59 +01:00
Jonathan Wakely e59e183f69 LWG2707 init filesystem::path from string_type&&
* include/experimental/bits/fs_path.h (path::path(string_type&&))
	(path::operator=(string&&), path::assign(string_type&&)): Define
	construction and assignment from string_type rvalues (LWG 2707).

From-SVN: r241416
2016-10-21 18:00:53 +01:00
Jonathan Wakely f3070dab7a Make std::enable_shared_from_this cope with ambiguity
* include/backward/auto_ptr.h (__shared_ptr(auto_ptr&&)): Call
	_M_enable_shared_from_this_with instead of
	__enable_shared_from_this_helper.
	* include/bits/shared_ptr.h (__enable_shared_from_this_helper):
	Remove overload for std::enable_shared_from_this..
	(__enable_shared_from_this_base): Define friend function to select a
	std::enable_shared_from_this base class.
	* include/bits/shared_ptr_base.h (__enable_shared_from_this_helper):
	Remove all overloads.
	(__shared_ptr): Change all relevant constructors to call
	_M_enable_shared_from_this_with instead of
	__enable_shared_from_this_helper.
	(__shared_ptr::__efst_base_t, __shared_ptr::__has_efst_base): Helpers
	to detect accessible and unambiguous enable_shared_from_this bases.
	(__shared_ptr::_M_enable_shared_from_this_with): New function to
	replace __enable_shared_from_this_helper overloads.
	(__enable_shared_from_this_helper): Remove overload for
	std::__enable_shared_from_this.
	(__enable_shared_from_this_base): Define friend function to select a
	std::__enable_shared_from_this base class.
	* include/experimental/bits/shared_ptr.h (experimental::shared_ptr):
	Change relevant constructors to call _M_enable_shared_from_this_with.
	(experimental::shared_ptr::__efst_base_t)
	(experimental::shared_ptr::__has_efst_base): Helpers to detect
	accessible and unambiguous enable_shared_from_this bases.
	(experimental::shared_ptr::_M_enable_shared_from_this_with): Define.
	(experimental::__enable_shared_from_this_helper): Remove overload for
	std::experimental::enable_shared_from_this.
	(experimental::__expt_enable_shared_from_this_base): Define friend
	function to select a std::experimental::enable_shared_from_this base.
	* testsuite/experimental/memory/shared_ptr/cons/
	enable_shared_from_this.cc: New test.
	* testsuite/experimental/memory/shared_ptr/cons/unique_ptr_ctor.cc:
	Adjust expected behaviour for shared_ptr<A[]>.

From-SVN: r241353
2016-10-19 21:13:14 +01:00
Jonathan Wakely 84870b6bb2 Fix std::experimental::shared_ptr SFINAE constraints
* include/experimental/bits/shared_ptr.h
	(__shared_ptr<__libfund_v1<_Tp, false>, _Lp>::_Compatible): Just use
	is_convertible for non-array specialization.
	(__shared_ptr<__libfund_v1<_Tp, false>, _Lp>::_UniqCompatible): New
	constraint for conversions from unique_ptr.
	(__shared_ptr<__libfund_v1<_Tp, false>, _Lp>::__shared_ptr): Constrain.
	(__shared_ptr<__libfund_v1<_Tp, false>, _Lp>::reset): Likewise.
	(__sp_compatible_v): New variable template for trait.
	(__sp_is_constructible): New trait to check shared_ptr constraints.
	(__sp_is_constructible_v): New variable template for trait.
	(__shared_ptr<__libfund_v1<_Tp, true>, _Lp>::_SafeConv): New
	constraint for construction/reset, using __sp_is_constructible_v.
	(__shared_ptr<__libfund_v1<_Tp, true>, _Lp>::_UniqCompatible): New
	constraint for conversions from unique_ptr.
	(__shared_ptr<__libfund_v1<_Tp, true>, _Lp>::__shared_ptr): Constrain.
	(__shared_ptr<__libfund_v1<_Tp, true>, _Lp>::reset): Likewise.
	(shared_ptr::_SafeConv): Constraint for checking constructors.
	(shared_ptr(Tp1*), shared_ptr(_Tp1, _Deleter))
	(shared_ptr(_Tp1, _Deleter, _Alloc)): Constrain with _SafeConv.
	(shared_ptr(const weak_ptr<_Tp1>&)): Constrain with _Compatible.
	(shared_ptr(auto_ptr<_Tp1>&&)): Fix, remove TODO.
	* testsuite/experimental/memory/shared_ptr/cons/pointer_ctor.cc:
	Remove tests using invalid conversions.
	* testsuite/experimental/memory/shared_ptr/cons/pointer_ctor_neg.cc:
	New test.
	* testsuite/experimental/memory/shared_ptr/cons/torture.cc: New test.
	* testsuite/experimental/memory/shared_ptr/modifiers/reset.cc: Remove
	tests using invalid conversions.
	* testsuite/experimental/memory/shared_ptr/modifiers/reset_neg.cc: New
	test.
	* testsuite/experimental/memory/shared_ptr/observers/use_count.cc:
	Remove tests using invalid conversions.

From-SVN: r241331
2016-10-19 10:35:03 +01:00
Jonathan Wakely 6dddab0845 Fix indentation of experimental::shared_ptr code
* include/experimental/bits/shared_ptr.h: Fix indentation.

From-SVN: r241311
2016-10-18 19:41:43 +01:00
Jonathan Wakely 8a9ff71f5b Fix typos in experimental::shared_ptr
* include/experimental/bits/shared_ptr.h (shared_ptr(shared_ptr&&)):
	Remove const from parameter.
	(operator<(const shared_ptr<T>&, nullptr_t)): Use correct
	specialization of std::less.
	* testsuite/experimental/memory/shared_ptr/comparison/comparison.cc:
	Test comparison with nullptr and actually call test functions.

From-SVN: r241310
2016-10-18 19:30:38 +01:00
Jonathan Wakely 12d3f34b33 PR77994 Convert std::sample size argument to suitable type
PR libstdc++/77994
	* include/bits/stl_algo.h (sample): Convert size argument to iterator
	difference type.
	* include/experimental/algorithm (experimental::sample): Likewise.
	* testsuite/25_algorithms/sample/2.cc: New test.

From-SVN: r241245
2016-10-17 15:39:23 +01:00
Jonathan Wakely d67dd0be94 Avoid #include <functional> in other headers
* include/bits/shared_ptr_base.h: Include <functional>.
	[!__cpp_rtti]: Do not include <typeinfo>.
	* include/experimental/array: Do not include <functional>.
	* include/experimental/memory: Include <bits/functional_hash.h>
	instead of <functional>.
	* include/experimental/propagate_const: Include <bits/stl_function.h>,
	<bits/functional_hash.h>, and <bits/move.h> instead of <functional>.
	* include/experimental/tuple: Do not include <functional>.
	* include/std/future: Include <functional>.
	* include/std/memory: Do not include <functional>.
	* include/std/mutex: [_GLIBCXX_HAVE_TLS]: Likewise.
	* testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc: Add
	missing includes.
	* testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise.
	* testsuite/20_util/specialized_algorithms/memory_management_tools/
	1.cc: Likewise.
	* testsuite/30_threads/call_once/60497.cc: Likewise.
	* testsuite/30_threads/lock/2.cc: Likewise.
	* testsuite/30_threads/thread/native_handle/cancel.cc: Likewise.
	* testsuite/experimental/algorithm/sample.cc: Likewise.
	* testsuite/experimental/array/make_array.cc: Likewise.
	* testsuite/experimental/array/neg.cc: Likewise. Adjust dg-error line.
	* testsuite/experimental/propagate_const/assignment/move_neg.cc:
	Adjust dg-error lines.
	* testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements2.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements3.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements4.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements5.cc: Likewise.

From-SVN: r241131
2016-10-13 17:59:19 +01:00
Jonathan Wakely 10482a6598 Qualify use of std::declval to avoid ADL
* include/experimental/propagate_const (element_type): Qualify
	declval.

From-SVN: r241129
2016-10-13 17:41:10 +01:00
Jonathan Wakely 5117a23e9f Use normal mode containers in searchers
* include/experiumental/functional (boyer_moore_searcher)
	(__boyer_moore_map_base, __boyer_moore_array_base): Qualify containers
	with _GLIBCXX_STD_C.
	* include/std/functional: Likewise.

From-SVN: r241126
2016-10-13 16:50:35 +01:00
Jonathan Wakely e7722f1106 Define std::sample for C++17
* doc/xml/manual/status_cxx2017.xml: Add std::sample status.
	* doc/html/*: Regenerate.
	* include/experimental/algorithm (__sample): Move to bits/stl_algo.h
	and into namespace std.
	* include/bits/stl_algo.h (__sample): Define here. Fix invalid use
	of input iterator. Defend against overloaded comma operator.
	(sample): Define for C++17.
	* testsuite/25_algorithms/sample/1.cc: New test.

From-SVN: r241062
2016-10-12 16:26:48 +01:00
Jonathan Wakely 7571121f10 Remove redundant const qualifliers from string_view
* include/experimental/string_view (basic_string_view::_S_compare):
	Remove redundant const from return type.
	* include/std/string_view (basic_string_view:_S_compare): Likewise.

From-SVN: r240981
2016-10-11 11:33:24 +01:00
Jonathan Wakely f2e79496bf LWG 2733, LWG 2759 reject bool in gcd and lcm
* include/experimental/numeric (gcd, lcm): Make bool arguments
	ill-formed.
	* include/std/numeric (gcd, lcm): Likewise.
	* testsuite/26_numerics/gcd/gcd_neg.cc: New test.
	* testsuite/26_numerics/lcm/lcm_neg.cc: New test.

From-SVN: r240919
2016-10-10 13:17:34 +01:00
Jonathan Wakely 78ec9c15be PR 70564 disambiguate constructors for not_fn call wrapper
PR libstdc++/70564
	* include/experimental/functional (_Not_fn): Remove.
	(not_fn): Use std::_Not_fn.
	* include/std/functional (_Not_fn): Add second parameter to
	disambiguate copying from initialization by not_fn. Define for C++14.
	(not_fn): Add second argument to initialization.
	* testsuite/20_util/not_fn/1.cc: Copy call wrapper using
	direct-initialization.

From-SVN: r240778
2016-10-05 13:01:36 +01:00
Jonathan Wakely 606dda21c8 Define std::gcd and std::lcm for C++17
* doc/xml/manual/status_cxx2017.xml: Update gcd/lcm status.
	* doc/html/*: Regenerate.
	* include/experimental/numeric (__abs): Move to <numeric>.
	(gcd, lcm): Use __detail::gcd and __detail::lcm.
	* include/std/numeric (__detail::__abs_integral)
	(__detail::__gcd, __detail::__lcm): Define.
	(gcd, lcm): Define for C++17.
	* testsuite/26_numerics/gcd/1.cc: New test.
	* testsuite/26_numerics/lcm/1.cc: New test.
	* testsuite/experimental/numeric/gcd.cc: Swap contents with ...
	* testsuite/experimental/numeric/lcd.cc: ... this.

From-SVN: r240723
2016-10-03 18:01:10 +01:00
Jonathan Wakely e347987da8 Fix libstdc++ versioned namespace build
PR libstdc++/68323
	PR libstdc++/77794
	* config/abi/pre/gnu-versioned-namespace.ver: Add exports for
	__cxa_thread_atexit and __gnu_cxx::__freeres.
	* include/Makefile.am: Add <experimental/bits/lfts_config.h>
	* include/Makefile.in: Regenerate.
	* include.bits/basic_string.h: Fix nesting of versioned namespaces.
	* include/bits/c++config: Declare versioned namespaces for literals.
	* include/bits/regex.h (basic_regex, match_results): Add workarounds
	for PR c++/59256.
	* include/bits/uniform_int_dist.h: Fix nesting of versioned namespace.
	* include/std/chrono: Likewise.
	* include/std/complex: Likewise.
	* include/std/string_view: Likewise.
	* include/std/variant: Likewise. Add workaround for PR c++/59256.
	* include/experimental/bits/fs_fwd.h: Declare versioned namespace.
	* include/experimental/bits/lfts_config.h: Declare versioned
	namespaces.
	* include/experimental/algorithm: Include
	<experimental/bits/lfts_config.h>.
	* include/experimental/any: Likewise.
	* include/experimental/bits/erase_if.h: Likewise.
	* include/experimental/chrono: Likewise.
	* include/experimental/functional: Likewise.
	* include/experimental/memory_resource: Likewise.
	* include/experimental/optional: Likewise.
	* include/experimental/propagate_const: Likewise.
	* include/experimental/random: Likewise.
	* include/experimental/ratio: Likewise.
	* include/experimental/system_error: Likewise.
	* include/experimental/tuple: Likewise.
	* include/experimental/type_traits: Likewise.
	* include/experimental/utility: Likewise.
	* include/experimental/string_view: Likewise. Fix nesting of
	versioned namespaces.
	* include/experimental/bits/string_view.tcc: Reopen inline namespace
	for non-inline function definitions.
	* testsuite/17_intro/using_namespace_std_exp_neg.cc: New test.
	* testsuite/20_util/duration/literals/range.cc: Adjust dg-error line.
	* testsuite/experimental/any/misc/any_cast_neg.cc: Likewise.
	* testsuite/experimental/propagate_const/assignment/move_neg.cc:
	Likewise.
	* testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements2.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements3.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements4.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements5.cc: Likewise.
	* testsuite/ext/profile/mutex_extensions_neg.cc: Likewise.

From-SVN: r240714
2016-10-03 15:35:28 +01:00
Jonathan Wakely 9e28a77462 Remove use of std::abs in experimental::{gcd,lcm}
PR libstdc++/77801
	* include/experimental/numeric: Include <numeric>.
	(__abs): Define.
	(gcd, lcm): Use __abs instead of std::abs.
	* testsuite/experimental/numeric/77801.cc: New test.
	* testsuite/experimental/numeric/gcd.cc: Test unsigned inputs.
	* testsuite/experimental/numeric/lcm.cc: Likewise.

From-SVN: r240656
2016-09-30 14:43:37 +01:00
Jonathan Wakely fd5effb17e Check for overflow in filesystem::last_write_time
* include/experimental/bits/fs_fwd.h (file_time_type): Simplify
	definition.
	* src/filesystem/ops.cc (file_time): Take error_code parameter and
	check for overflow.
	(do_copy_file, last_write_time): Pass error_code in file_time calls.
	* testsuite/experimental/filesystem/operations/last_write_time.cc:
	New.
	* testsuite/util/testsuite_fs.h (scoped_file): Define RAII helper.

From-SVN: r240587
2016-09-28 19:02:25 +01:00
Jonathan Wakely e6ee5bfd68 Define std::not_fn for C++17
* doc/xml/manual/status_cxx2017.xml: Update status of not_fn.
	* doc/html/*: Regenerate.
	* include/experimental/functional (_Not_fn, not_fn): Match C++17
	semantics.
	* include/std/functional (_Not_fn, not_fn): Define for C++17.
	* testsuite/20_util/not_fn/1.cc: New.
	* testsuite/experimental/functional/not_fn.cc: Test abstract class.
	Remove test for volatile-qualified wrapper.

From-SVN: r239623
2016-08-19 16:42:34 +01:00
Jonathan Wakely 285ee2fb11 Fix ambiguities in C++17 mode
* include/experimental/tuple (apply): Qualify call to __apply_impl.
	* include/std/tuple (apply): Likewise.
	* testsuite/experimental/system_error/value.cc: Fix ambiguities in
	C++17 mode.
	* testsuite/experimental/tuple/tuple_size.cc: Likewise.
	* testsuite/experimental/type_traits/value.cc: Likewise.

From-SVN: r239621
2016-08-19 16:42:11 +01:00
Jonathan Wakely 3e9f67e6a2 Add std::apply for C++17
* doc/xml/manual/status_cxx2017.xml: Add missing LFTSv2 features.
	* doc/html/manual/status.html: Regenerate.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/invoke.h: New header.
	(__invoke): Make constexpr. Add && to types in exception specification.
	* include/experimental/tuple (apply, __apply_impl): Fix non-reserved
	names. Include <bits/invoke.h> and use std::__invoke.
	* include/std/functional (__invfwd, __invoke_impl, __invoke): Move to
	new header.
	(invoke): Add && to types in exception specification.
	* include/std/tuple (apply, __apply_impl): Define for C++17.
	* testsuite/20_util/tuple/apply/1.cc: New test.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust dg-error
	lineno.

From-SVN: r239183
2016-08-06 01:06:02 +01:00
Jonathan Wakely 8b649cd3ba Fix naming, qualification and broken test for propagate_const
* include/experimental/propagate_const (propagate_const::__t): Rename
	to _M_t and remove comment. Qualify std::move and std::forward.
	* testsuite/experimental/propagate_const/cons/default.cc: Fix test.

From-SVN: r238611
2016-07-21 20:39:03 +01:00
Jonathan Wakely ea5ec6b7e0 Include header for std::__parallel::search
* include/experimental/functional: Include <parallel/algorithm> in
	Parallel Mode.

From-SVN: r238342
2016-07-14 16:43:17 +01:00
Ville Voutilainen 86c0ec1de1 Implement P0307R2, Making Optional Greater Equal Again.
* include/experimental/optional (_Has_addressof): Fix the comment.
	* include/std/optional (_Has_addressof): Likewise.
	(operator=(_Up&&)): Constrain.
	(operator=(const optional<_Up>&)): Likewise.
	(operator=(optional<_Up>&&)): Likewise.
	(__optional_relop_t): New.
	(operator==(const optional<_Tp>&, const optional<_Tp>&)): Constrain.
	(operator!=(const optional<_Tp>&, const optional<_Tp>&)):
	Constrain and make transparent.
	(operator<(const optional<_Tp>&, const optional<_Tp>&)): Constrain.
	(operator>(const optional<_Tp>&, const optional<_Tp>&)):
	Constrain and make transparent.
	(operator<=(const optional<_Tp>&, const optional<_Tp>&)): Likewise.
	(operator>=(const optional<_Tp>&, const optional<_Tp>&)): Likewise.
	(operator==(const optional<_Tp>&, const _Tp&): Constrain.
	(operator==(const _Tp&, const optional<_Tp>&)): Likewise.
	(operator!=(const optional<_Tp>&, _Tp const&)):
	Constrain and make transparent.
	(operator!=(const _Tp&, const optional<_Tp>&)): Likewise.
	(operator<(const optional<_Tp>&, const _Tp&)): Constrain.
	(operator<(const _Tp&, const optional<_Tp>&)): Likewise.
	(operator>(const optional<_Tp>&, const _Tp&)):
	Constrain and make transparent.
	(operator>(const _Tp&, const optional<_Tp>&)): Likewise.
	(operator<=(const optional<_Tp>&, const _Tp&)): Likewise.
	(operator<=(const _Tp&, const optional<_Tp>&)): Likewise.
	(operator>=(const optional<_Tp>&, const _Tp&)): Likewise.
	(operator>=(const _Tp&, const optional<_Tp>&)): Likewise.
	* testsuite/20_util/optional/constexpr/relops/2.cc: Adjust.
	* testsuite/20_util/optional/constexpr/relops/4.cc: Likewise.
	* testsuite/20_util/optional/relops/1.cc: Likewise.
	* testsuite/20_util/optional/relops/2.cc: Likewise.
	* testsuite/20_util/optional/relops/3.cc: Likewise.
	* testsuite/20_util/optional/relops/4.cc: Likewise.
	* testsuite/20_util/optional/requirements.cc: Add tests to verify
	that optional's relops are transparent and don't synthesize
	operators. Also test that assignment sfinaes.

From-SVN: r238292
2016-07-13 14:25:51 +03:00
Ville Voutilainen 6ffe854859 Implement LWG 2451, optional<T> should 'forward' T's implicit conversions.
Implement LWG 2451, optional<T> should 'forward' T's
	implicit conversions.
	* include/experimental/optional (__is_optional_impl, __is_optional):
	New.
	(optional()): Make constexpr and default.
	(optional(_Up&&), optional(const optional<_Up>&),
	optional(optional<_Up>&& __t): New.
	(operator=(_Up&&)): Constrain.
	(operator=(const optional<_Up>&), operator=(optional<_Up>&&)): New.
	* testsuite/experimental/optional/cons/value.cc:
	Add tests for the functionality added by LWG 2451.
	* testsuite/experimental/optional/cons/value_neg.cc: New.

From-SVN: r238049
2016-07-06 16:26:10 +03:00