summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
Commit message (Collapse)AuthorAgeFilesLines
* Fix tests that fail with _GLIBCXX_USE_CXX11_ABI=0Jonathan Wakely2019-04-263-8/+40
| | | | | | | | | | | | | | | | | The pmr::string typedef isn't available for the old COW string, so some tests that use it were failing. Backport from mainline 2019-04-26 Jonathan Wakely <jwakely@redhat.com> * testsuite/20_util/variant/run.cc: Use a new Hashable type to test hashing, because pmr::string depends on _GLIBCXX_USE_CXX11_ABI==1. * testsuite/21_strings/basic_string/hash/hash.cc [!_GLIBCXX_USE_CXX11_ABI]: Don't test pmr strings. * testsuite/21_strings/basic_string/hash/hash_char8_t.cc [!_GLIBCXX_USE_CXX11_ABI]: Likewise. From-SVN: r270612
* Make filesystem::path comparison operators hidden friends (LWG 3065)Jonathan Wakely2019-04-242-2/+2
| | | | | | | | | | | | | | This change revealed two testsuite bugs where some string comparisons only compiled by converting the strings to filesystem::path objects. * include/bits/fs_path.h (operator<, operator<=, operator>) (operator>=, operator==, operator!=): Make hidden friends, as per LWG 3065. * testsuite/27_io/filesystem/path/native/string-char8_t.cc: Fix string type in test. * testsuite/27_io/filesystem/path/native/string.cc: Likewise. From-SVN: r270558
* Fix basic_string_view typedefs and enforce preconditionsJonathan Wakely2019-04-2411-12/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The basic_string_view::pointer and basic_string_view::reference typedefs are supposed to refer to the non-const value type. In previous standards having traits_type::char_type different to value_type was simply undefined, but in the C++2a draft it's ill-formed, as changed by P1148R0. For std::basic_string and iostreams we might want to only enforce this conditionally for __cplusplus > 201703L but for std::basic_string_view we don't have backwards compatibility concerns. Also add assertions to verify the _CharT argument is a "char-like" type (non-array, trivial, standard layout type). Also remove the non-standard basic_string_view::_M_check and basic_string_view::_M_limit member functions, replacing them with non-member functions that will still exist even if basic_string_view is specialized by the program. * include/experimental/string_view (basic_string_view::pointer) (basic_string_view::reference): Fix to refer to non-const value_type. * include/bits/basic_string.h (basic_string): Use __sv_check and __sv_limit instead of basic_string_view::_M_check and basic_string_view::_M_limit. * include/std/string_view (__sv_check, __sv_limit): New helper functions to replace basic_string_view::_M_check and basic_string_view::_M_limit. (basic_string_view): Add static assertions to enforce ill-formed requirement for traits_type::char_type from P1148R0, and to enforce required properties of char-like types. (basic_string_view::pointer, basic_string_view::reference): Fix to refer to non-const value_type. (basic_string_view::operator[], basic_string_view::at) (basic_string_view::front, basic_string_view::back) (basic_string_view::data): Use const_reference and const_pointer typedefs for return types. (basic_string_view::_M_check, basic_string_view::_M_limit): Remove. (hash<wstring_view>): Fix argument_type typedef. * testsuite/21_strings/basic_string_view/modifiers/remove_prefix/ char/1.cc: Fix expected return type of basic_string_view::data(). * testsuite/21_strings/basic_string_view/modifiers/remove_prefix/ wchar_t/1.cc: Likewise. * testsuite/21_strings/basic_string_view/modifiers/remove_suffix/ char/1.cc: Likewise. * testsuite/21_strings/basic_string_view/modifiers/remove_suffix/ wchar_t/1.cc: Likewise. * testsuite/21_strings/basic_string_view/requirements/traits_neg.cc: New test. * testsuite/21_strings/basic_string_view/requirements/typedefs.cc: Check reference and pointer typedefs. * testsuite/experimental/string_view/requirements/typedefs.cc: Likewise. * testsuite/experimental/string_view/modifiers/remove_prefix/char/1.cc: Fix expected return type of basic_string_view::data(). * testsuite/experimental/string_view/modifiers/remove_prefix/wchar_t/ 1.cc: Likewise. * testsuite/experimental/string_view/modifiers/remove_suffix/char/1.cc: Likewise. * testsuite/experimental/string_view/modifiers/remove_suffix/wchar_t/ 1.cc: Likewise. From-SVN: r270548
* PR libstdc++/90220 Fix std::any_cast for array typesJonathan Wakely2019-04-241-0/+17
| | | | | | | | | | | | | | | | | | Although the std::any constructors use decay_t to determine the type of the contained value, std::any_cast should use the un-decayed type (and so always fail for function and array types that decay to pointers). Using remove_cv_t is correct, because the condition for std::any_cast to return non-null is operand.type() == typeid(T) and typeid ignores top-level cv-qualifiers. PR libstdc++/90220 * include/std/any (__any_caster): Use remove_cv_t instead of decay_t. Avoid a runtime check for types that can never be stored in std::any. * testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with array types. From-SVN: r270547
* PR libstdc++/90220 Fix std::any_cast for function pointersJonathan Wakely2019-04-241-0/+34
| | | | | | | | | | PR libstdc++/90220 (partial) * include/std/any (any_cast<T>(any*), any_cast<T>(const any*)): Do not attempt ill-formed static_cast to pointers to non-object types. * testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with function types. From-SVN: r270538
* Avoid -Wcatch-value warning in testsuiteJonathan Wakely2019-04-241-1/+1
| | | | | | | * testsuite/20_util/variant/run.cc: Catch exception by reference to prevent -Wcatch-value warning. From-SVN: r270527
* Implement LWG 2904 for std::variant assignmentJonathan Wakely2019-04-241-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | * include/std/variant (__variant_construct): Use template parameter type instead of equivalent decltype-specifier. (_Move_ctor_base<false, Types...>::_Move_ctor_base(_Move_ctor_base&&)): Replace forward with move. (_Move_ctor_base<false, Types...>::_M_destructive_move) (_Move_ctor_base<false, Types...>::_M_destructive_copy) (_Move_ctor_base<true, Types...>::_M_destructive_move) (_Move_ctor_base<true, Types...>::_M_destructive_copy): Only set the index after construction succeeds. (_Copy_assign_base<false, Types...>::operator=): Remove redundant if-constexpr checks that are always true. Use __remove_cvref_t instead of remove_reference so that is_nothrow_move_constructible check doesn't use a const rvalue parameter. In the potentially-throwing case construct a temporary and move assign it, as per LWG 2904. (_Move_assign_base<false, Types...>::operator=): Remove redundant if-constexpr checks that are always true. Use emplace as per LWG 2904. (variant::operator=(T&&)): Only use emplace conditionally, otherwise construct a temporary and move assign from it, as per LWG 2904. * testsuite/20_util/variant/exception_safety.cc: Check that assignment operators have strong exception safety guarantee. From-SVN: r270525
* Implement correct std::variant triviality rules from P0602R4Jonathan Wakely2019-04-231-7/+7
| | | | | | | | | | | | | | | | The std::variant move assignment operator should not be trivial if the variant is not trivially move constructible. * include/std/variant (__detail::__variant::_Traits): Make _S_trivial_copy_assign depend on _S_trivial_copy_ctor and make _S_trivial_move_assign depend on _S_trivial_move_ctor, as per P0602R4. (__detail::__variant::_Copy_assign_alias): Only depend on _S_trivial_copy_assign, which subsumes _S_trivial_copy_ctor now. * testsuite/20_util/variant/compile.cc: Correct checks for trivial move assignment operators. From-SVN: r270510
* PR libstdc++/90165 constrain variant(T&&) constructorJonathan Wakely2019-04-231-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Also refactor some constraints slightly to be more readable. PR libstdc++/90165 * include/std/variant (variant::__not_self): New helper for the is_same_v<remove_cvref_t<T>, variant>==false constraints. (variant::__to_type_impl): Remove. (variant::__to_type): Add default argument to check pack size, instead of using __to_type_impl. (variant::__accepted_type): Add default argument using __not_self. (variant::__is_in_place_tag, variant::__not_in_place_tag): New helpers for variant(T&&) constructor constraint. (variant::variant(T&&)): Use __not_in_place_tag in constraints. Extract __accepted_type into a named template parameter for reuse in other constraints and in the exception specification. (variant::variant(in_place_type_t<T>, Args&&...)) (variant::variant(in_place_type_t<T>, initializer_list<U>, Args&&...)) (variant::variant(in_place_index_t<T>, Args&&...)) (variant::variant(in_place_index_t<T>, initializer_list<U>, Args&&...)) (variant::operator=T&&)): Remove redundant && from trait arguments. * testsuite/20_util/variant/compile.cc: Check variant(T&&) constructor isn't used for in_place_type or in_place_index arguments. From-SVN: r270509
* Corrections for C++2a std::unwrap_reference traitsJonathan Wakely2019-04-231-1/+1
| | | | | | | | | | | | | The P0318R1 paper added to the C++2a draft recently was not the latest version of the paper, and should have included these changes. These changes will be made to the working draft via a Defect Report, so I'm applying them to libstdc++ now. * include/std/type_traits (unwrap_reference_t): Define for C++2a. (unwrap_ref_decay): Remove inheritance from unwrap_reference. * testsuite/20_util/unwrap_reference/1.cc: Adjust test to use alias. From-SVN: r270506
* Fix std::variant regression caused by never-valueless optimizationJonathan Wakely2019-04-232-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A regression was introduced by the recent changes to provide the strong exception safety guarantee for "never valueless" types that have O(1), non-throwing move assignment. The problematic code is: else if constexpr (__detail::__variant::_Never_valueless_alt<type>()) { // This construction might throw: variant __tmp(in_place_index<_Np>, __il, std::forward<_Args>(__args)...); // But _Never_valueless_alt<type> means this won't: *this = std::move(__tmp); } When the variant is not assignable, the assignment is ill-formed, so should not be attempted. When the variant has a copy assignment operator but not a move assignment operator, the assignment performs a copy assignment and that could throw, so should not be attempted. The solution is to only take that branch when the variant has a move assignment operator, which is determined by the _Traits::_S_move_assign constant. When that is false the strong exception safety guarantee is not possible, and so the __never_valueless function should also depend on _S_move_assign. While testing the fixes for this I noticed that the partial specialization _Never_valueless_alt<basic_string<C,T,A>> incorrectly assumed that is_nothrow_move_constructible<basic_string<C,T,A>> is always true, but that's wrong for fully-dynamic COW strings. Fix the partial specialization, and improve the comment describing _Never_valueless_alt to be clear it depends on move construction as well as move assignment. Finally, I also observed that _Variant_storage<false, T...>::_M_valid() was not taking advantage of the __never_valueless<T...>() function to avoid a runtime check. Only the _Variant_storage<true, T...>::_M_valid() function was using __never_valueless. That is also fixed. PR libstdc++/87431 * include/bits/basic_string.h (_Never_valueless_alt): Make partial specialization also depend on is_nothrow_move_constructible. * include/std/variant (__detail::__variant::__never_valueless()): Only true if the variant would have a move assignment operator. (__detail::__variant::_Variant_storage<false, T...>::_M_valid()): Check __never_valueless<T...>(). (variant::emplace): Only perform non-throwing move assignments for never-valueless alternatives if the variant has a move assignment operator. * testsuite/20_util/variant/compile.cc: Check that never-valueless types can be emplaced into non-assignable variants. * testsuite/20_util/variant/run.cc: Check that never-valueless types don't get copied when emplaced into non-assignable variants. From-SVN: r270502
* libstdc++-v3 Skip tests on Darwin8-10.Iain Sandoe2019-04-215-0/+5
| | | | | | | | | | | | | | | | | | | | | These earlier Darwin versions have “FP_≈” inside a comment in architecture/{ppc,i386}/math.h, which is included by math.h which causes the tests to fail. The intent of the tests (i.e. to ensure that the library itself does not emit non-ascii) is covered by other platforms, including later Darwin editions. 2019-04-21 Iain Sandoe <iain@sandoe.co.uk> * testsuite/17_intro/headers/c++1998/charset.cc: Skip for Darwin8 to Darwin10. * testsuite/17_intro/headers/c++2011/charset.cc: Likewise. * testsuite/17_intro/headers/c++2014/charset.cc: Likewise. * testsuite/17_intro/headers/c++2017/charset.cc: Likewise. * testsuite/17_intro/headers/c++2020/charset.cc: Likewise. From-SVN: r270479
* PR c++/90047 - ICE with enable_if alias template.Jason Merrill2019-04-1729-0/+56
| | | | | | | | | | | | | | | | | In order to make alias templates useful for SFINAE we instantiate them under the prevailing 'complain' argument, so an error encountered while instantiating during SFINAE context is silent. The problem in this PR comes when we later look up the erroneous instantiation and don't give an error at that point. Fixed by not adding an erroneous instantiation to the hash table, so we instantiate it again when needed and get the error. This required changes to a number of tests, which previously said "substitution failed:" with no explanation of what the failure was; now we properly explain. * pt.c (tsubst_decl) [TYPE_DECL]: Don't put an erroneous decl in the hash table when we're in SFINAE context. From-SVN: r270433
* PR libstdc++/90105 make forward_list::sort stableJonathan Wakely2019-04-172-7/+97
| | | | | | | | | | | | | | | | | While testing the fix I also discovered that operator== assumes the elements are comparable with operator!= which is not required. PR libstdc++/90105 * include/bits/forward_list.h (operator==): Do not use operator!= to compare elements. (forward_list<T, A>::sort(Comp)): When elements are equal take the one earlier in the list, so that sort is stable. * testsuite/23_containers/forward_list/operations/90105.cc: New test. * testsuite/23_containers/forward_list/comparable.cc: Test with types that meet the minimum EqualityComparable and LessThanComparable requirements. Remove irrelevant comment. From-SVN: r270427
* Fix condition for std::variant to be copy constructibleJonathan Wakely2019-04-172-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | The standard says the std::variant copy constructor is defined as deleted unless all alternative types are copy constructible, but we were making it also depend on move constructible. Fix the condition and enhance the tests to check the semantics with pathological copy-only types (i.e. supporting copying but having deleted moves). The enhanced tests revealed a regression in copy assignment for non-trivial alternative types, where the assignment would not be performed because the condition in the _Copy_assign_base visitor is false: is_same_v<remove_reference_t<T&>, remove_reference_t<const T&>>. * include/std/variant (__detail::__variant::_Traits::_S_copy_assign): Do not depend on whether all alternative types are move constructible. (__detail::__variant::_Copy_assign_base::operator=): Remove cv-quals from the operand when deciding whether to perform the assignment. * testsuite/20_util/variant/compile.cc (DeletedMoves): Define type with deleted move constructor and deleted move assignment operator. (default_ctor, copy_ctor, move_ctor, copy_assign, move_assign): Check behaviour of variants with DeletedMoves as an alternative. * testsuite/20_util/variant/run.cc (DeletedMoves): Define same type. (move_ctor, move_assign): Check that moving a variant with a DeletedMoves alternative falls back to copying instead of moving. From-SVN: r270425
* Remove unnecessary string literals from static_assert in C++17 testsJonathan Wakely2019-04-171-125/+125
| | | | | | | | | | The string literal is optional in C++17 and all these are empty so add no value. * testsuite/20_util/variant/compile.cc: Remove empty string literals from static_assert declarations. From-SVN: r270424
* Fix tests for std::variant to match original intentionJonathan Wakely2019-04-171-5/+9
| | | | | | | | | | * testsuite/20_util/variant/compile.cc (MoveCtorOnly): Fix type to actually match its name. (MoveCtorAndSwapOnly): Define new type that adds swap to MoveCtorOnly. (test_swap()): Fix result for MoveCtorOnly and check MoveCtorAndSwapOnly. From-SVN: r270423
* Add constexpr to std::optional::value_or(U&&)&&Jonathan Wakely2019-04-172-4/+68
| | | | | | | | | | | | | | | In C++1z drafts up to N4606 the constexpr keyword was missing from the detailed description of this function, despite being shown in the class synopsis. That was fixed editorially for N4618, but our implementation was not corrected to match. * include/std/optional (optional::value_or(U&&) &&): Add missing constexpr specifier. * testsuite/20_util/optional/constexpr/observers/4.cc: Check value_or for disengaged optionals and rvalue optionals. * testsuite/20_util/optional/observers/4.cc: Likewise. From-SVN: r270409
* Fix typo in effective-target checkJonathan Wakely2019-04-101-1/+1
| | | | | | | * testsuite/lib/libstdc++.exp (check_v3_target_parallel_mode): Fix typo. From-SVN: r270259
* PR libstdc++/89851 Add testcase for std::variant equalityJonathan Wakely2019-04-101-0/+40
| | | | | | | | | | Add a test for the regression introduced with r269422 and fixed with r270056. PR libstdc++/89851 * testsuite/20_util/variant/89851.cc: New test. From-SVN: r270249
* Add comments and style fixes to <variant>Jonathan Wakely2019-04-091-0/+22
| | | | | | | | | | | | | | * include/std/variant: Adjust whitespace. Add comments. (_Multi_array): Leave primary template undefined. (_Multi_array<_Tp>): Define partial specialization for base case of recursion. (__gen_vtable_impl, __gen_vtable): Remove redundant && from type which is always a reference. (__gen_vtable::_S_apply()): Remove function, inline body into default member initializer. * testsuite/20_util/variant/visit.cc: Test with noncopyable types. From-SVN: r270238
* Fix std::visit to support arbitrary callablesJonathan Wakely2019-04-091-0/+73
| | | | | | | | | | | | | The __visitor_result_type helper didn't use std::invoke and so didn't compile when the visitor was a pointer-to-member rather than a function object. Use std::invoke_result instead. * include/std/variant (__variant_idx_cookie): Add member type. (__visitor_result_type): Remove. (__do_visit): Use invoke_result instead of __visitor_result_type. * testsuite/20_util/variant/visit.cc: New test. From-SVN: r270237
* PR libstdc++/90008 remove unused capture from variant rel opsJonathan Wakely2019-04-091-0/+37
| | | | | | | | | PR libstdc++/90008 * include/std/variant (_VARIANT_RELATION_FUNCTION_TEMPLATE): Remove unused capture. * testsuite/20_util/variant/90008.cc: New test. From-SVN: r270236
* Fix visit<R> for variant.Ville Voutilainen2019-04-082-0/+59
| | | | | | | | | | | | | | | | | | | | * include/std/variant (__do_visit): Add a template parameter for enforcing same return types for visit. (__gen_vtable_impl): Likewise. (_S_apply_single_alt): Adjust. (__visit_invoke_impl): New. Handle casting to void. (__do_visit_invoke): New. Enforces same return types. (__do_visit_invoke_r): New. Converts return types. (__visit_invoke): Adjust. (__gen_vtable): Add a template parameter for enforcing same return types for visit. * testsuite/20_util/variant/visit_r.cc: Add a test for a visitor with different return types. * testsuite/20_util/variant/visit_neg.cc: New. Ensures that visitors with different return types don't accidentally compile with regular visitation. From-SVN: r270216
* [testsuite,libstdc++-v3] Fix 27_io/filesystem/iterators/caching.ccChristophe Lyon2019-04-081-0/+1
| | | | | | | | | 2019-04-08 Christophe Lyon <christophe.lyon@linaro.org> * testsuite/27_io/filesystem/iterators/caching.cc: Add dg-require-filesystem-ts. From-SVN: r270199
* Implement std::visit<R> for C++2a (P0655R1)Jonathan Wakely2019-04-051-0/+49
| | | | | | | | * doc/xml/manual/status_cxx2020.xml: Update status. * include/std/variant (visit<R>): Define for C++2a (P0655R1). * testsuite/20_util/variant/visit_r.cc: New test. From-SVN: r270176
* PR libstdc++/89986 export directory_iterator::incrementJonathan Wakely2019-04-051-0/+9
| | | | | | | | | PR libstdc++/89986 * config/abi/pre/gnu.ver: Add missing exports. * testsuite/27_io/filesystem/iterators/directory_iterator.cc: Test increment member. From-SVN: r270174
* Share all recursive_directory_iterator state [LWG 2708]Jonathan Wakely2019-04-052-0/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement the proposed resolution of LWG 2708 by moving the _M_options and _M_pending members out of the recursive_directory_iterator into the shared _Dir_stack object. Because _Dir_stack is an opaque type, the member functions that access the _M_options and _M_pending variables cannot be inline. Move them into the library. As a drive-by fix, add noexcept to the non-throwing member functions of recursive_directory_iterator. * config/abi/pre/gnu.ver: Export new symbols. * include/bits/fs_dir.h (recursive_directory_iterator::options()) (recursive_directory_iterator::recursion_pending()) (recursive_directory_iterator::disable_recursion_pending()): Remove inline definitions. Make noexcept. (recursive_directory_iterator::depth()) (recursive_directory_iterator::operator*()) (recursive_directory_iterator::operator->()): Make noexcept. (recursive_directory_iterator::_M_options) (recursive_directory_iterator::_M_pending): Remove data members. * src/c++17/fs_path.cc (_Dir_stack): Add constructor and data members. (recursive_directory_iterator::recursive_directory_iterator): Remove ctor-initializer. Use new constructor for _Dir_stack. (recursive_directory_iterator::options()) (recursive_directory_iterator::recursion_pending()) (recursive_directory_iterator::disable_recursion_pending()): Add non-inline definitions. (recursive_directory_iterator::depth()): Make noexcept. (recursive_directory_iterator::increment(error_code&)) (recursive_directory_iterator::pop(error_code&)): Adjust to new location of options and recursion_pending members. * testsuite/27_io/filesystem/iterators/recursion_pending.cc: New test. * testsuite/util/testsuite_fs.h (__gnu_test::scoped_file): Add user-declared move constructor and assignment operator, to make the type move-only. From-SVN: r270173
* Fix directory_iterator handling of DT_UNKNOWNJonathan Wakely2019-04-051-0/+75
| | | | | | | | | | | | | | We need to handle DT_UNKNOWN earlier, not only during directory recursion, so that the cached file_type value in the directory_entry won't be used. * src/c++17/fs_dir.cc (_Dir::advance(bool, error_code&)): Handle d_type == DT_UNKNOWN immediately. (_Dir::should_recurse(bool, error_code&)): Remove file_type::unknown handling here. * testsuite/27_io/filesystem/iterators/caching.cc: New test. From-SVN: r270172
* Make filesystem::path safe for self assignmentJonathan Wakely2019-04-051-0/+18
| | | | | | | | | | | | | The standard says "If *this and p are the same object, has no effect." Previously we ended up clearing the path. * include/bits/fs_path.h (path::operator=(path&&)): Check for self assignment. * src/c++17/fs_path.cc (path::operator=(const path&)): Likewise. * testsuite/27_io/filesystem/path/assign/copy.cc: Test self assignment. From-SVN: r270171
* PR libstdc++/87431 re-adjust never-valueless optimizationsJonathan Wakely2019-04-053-3/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid creating arbitrarily large objects on the stack when emplacing trivially copyable objects into a variant. Currently we provide the strong exception-safety guarantee for all trivially copyable types, by constructing a second variant and then doing a non-throwing move assignment from the temporary. This patch restricts that behaviour to trivially copyable types that are no larger than 256 bytes. For larger types the object will be emplaced directly into the variant, and if its initialization throws then the variant becomes valueless. Also implement Antony Polukhin's suggestion to whitelist specific types that are not trivially copyable but can be efficiently move-assigned. Emplacing those types will never cause a variant to become valueless. The whitelisted types are: std::shared_ptr, std::weak_ptr, std::unique_ptr, std::function, and std::any. Additionally, std::basic_string, std::vector, and __gnu_debug::vector are whitelisted if their allocator traits give them a non-throwing move assignment operator. Specifically, this means std::string is whitelisted, but std::pmr::string is not. As part of this patch, additional if-constexpr branches are added for the cases where the initialization is known to be non-throwing (so the overhead of the try-catch block can be avoided) and where a scalar is being produced by a potentially-throwing conversion operator (so that the overhead of constructing and move-assigning a variant is avoided). These changes should have no semantic effect, just better codegen. PR libstdc++/87431 (again) * include/bits/basic_string.h (__variant::_Never_valueless_alt): Define partial specialization for basic_string. * include/bits/shared_ptr.h (_Never_valueless_alt): Likewise for shared_ptr and weak_ptr. * include/bits/std_function.h (_Never_valueless_alt): Likewise for function. * include/bits/stl_vector.h (_Never_valueless_alt): Likewise for vector. * include/bits/unique_ptr.h (_Never_valueless_alt): Likewise for unique_ptr. * include/debug/vector (_Never_valueless_alt): Likewise for debug vector. * include/std/any (_Never_valueless_alt): Define explicit specialization for any. * include/std/variant (_Never_valueless_alt): Define primary template. (__never_valueless): Use _Never_valueless_alt instead of is_trivially_copyable. (variant::emplace<N>(Args&&...)): Add special case for non-throwing initializations to avoid try-catch overhead. Add special case for scalars produced by potentially-throwing conversions. Use _Never_valueless_alt instead of is_trivially_copyable for the remaining strong exception-safety cases. (variant::emplace<N>(initializer_list<U>, Args&&...)): Likewise. * testsuite/20_util/variant/87431.cc: Run both test functions. * testsuite/20_util/variant/exception_safety.cc: New test. * testsuite/20_util/variant/run.cc: Use pmr::string instead of string, so the variant becomes valueless. From-SVN: r270170
* Define std::hash specializations for C++17 PMR stringsJonathan Wakely2019-04-032-0/+118
| | | | | | | | | | | | | | These hash specializations should have been added when the pmr::string and related typedefs were added. * include/std/string (__hash_string_base): New class template defining operator() for hashing strings. (hash<pmr::string>, hash<pmr::u8string>, hash<pmr::u16string>) (hash<pmr::u32string>, hash<pmr::wstring>): Define for C++17. * testsuite/21_strings/basic_string/hash/hash.cc: New test. * testsuite/21_strings/basic_string/hash/hash_char8_t.cc: New test. From-SVN: r270116
* PR libstdc++/85965 delay static assertions until types are completeJonathan Wakely2019-03-2610-10/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The static assertions added for PR libstdc++/48101 were at class scope and so were evaluated too eagerly, when it might not be possible to determine whether the function objects are invocable with the key types. The problematic cases are where the key type is not known to be convertible to the argument type(s) of the function object until later, after a type has been completed. Specifically, if the key type is a pointer to a derived class and the function object's argument type is a pointer to a base class, then the derived-to-base conversion is only valid once the derived type is complete. By moving the static assertions to the destructor they will only be evaluated when the destructor is instantiated, at which point whether the key type can be passed to the function object should be knowable. The ideal place to do the checks would be only when the function objects are actually invoked, but that would mean adding the checks in numerous places, so the destructor is used instead. The tests need to be adjusted because the "required from here" line is now the location of the destructor, not the point of instantiation in the test file. For the map and multimap tests which check two specializations, the dg-error matching the assertion text matches both cases. Also check the diagnostic output for the template arguments, to ensure both specializations trigger the assertion. PR libstdc++/85965 * include/bits/hashtable.h (_Hashtable): Move static assertions to destructor so they are not evaluated until the _Key type is complete. * include/bits/stl_tree.h (_Rb_tree): Likewise. * testsuite/23_containers/set/85965.cc: New test. * testsuite/23_containers/unordered_set/85965.cc: New test. * testsuite/23_containers/map/48101_neg.cc: Replace "here" errors with regexp matching the corresponding _Rb_tree specialization. * testsuite/23_containers/multimap/48101_neg.cc: Likewise. * testsuite/23_containers/multiset/48101_neg.cc: Remove "here" error. * testsuite/23_containers/set/48101_neg.cc: Likewise. * testsuite/23_containers/unordered_map/48101_neg.cc: Likewise. * testsuite/23_containers/unordered_multimap/48101_neg.cc: Likewise. * testsuite/23_containers/unordered_multiset/48101_neg.cc: Likewise. * testsuite/23_containers/unordered_set/48101_neg.cc: Likewise. From-SVN: r269949
* Integrate C++17 parallel algorithmsThomas Rodgers2019-03-2156-0/+8945
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the Intel implementation of the C++17 parallel algorithms, which has been donated to both GCC and LLVM. The upstream project is at - https://reviews.llvm.org/source/pstl/ The new files in the include/pstl sub-directory are covered by the LICENSE.txt in that sub-directory, as are the tests in testsuite/**/pstl/* * include/Makefile.am (std_header): Add ${std_srcdir}/execution. (pstl_srcdir, pstl_builddir, pstl_headers): New variables. (allstamped): Add stamp-pstl. (install-headers): Add ptsl_builddir. * include/Makefile.in: Regenerate. * include/bits/c++config: Add pstl configuration. * include/pstl/LICENSE.txt: New file. * include/pstl/algorithm_fwd.h: New file. * include/pstl/algorithm_impl.h: New file. * include/pstl/execution_defs.h: New file. * include/pstl/execution_impl.h: New file. * include/pstl/glue_algorithm_defs.h: New file. * include/pstl/glue_algorithm_impl.h: New file. * include/pstl/glue_execution_defs.h: New file. * include/pstl/glue_memory_defs.h: New file. * include/pstl/glue_memory_impl.h: New file. * include/pstl/glue_numeric_defs.h: New file. * include/pstl/glue_numeric_impl.h: New file. * include/pstl/memory_impl.h: New file. * include/pstl/numeric_fwd.h: New file. * include/pstl/numeric_impl.h: New file. * include/pstl/parallel_backend.h: New file. * include/pstl/parallel_backend_tbb.h: New file. * include/pstl/parallel_backend_utils.h: New file. * include/pstl/parallel_impl.h: New file. * include/pstl/pstl_config.h: New file. * include/pstl/unseq_backend_simd.h: New file. * include/pstl/utils.h: New file. * include/std/algorithm: Include parallel algorithm implementations. * include/std/execution: New file. * include/std/memory: Include parallel algorithm implementations. * include/std/numeric: Include parallel algorithm implementations. * include/std/version: Add parallel algorithms feature test macro. * testsuite/util/pstl/pstl_test_config.h: New file. * testsuite/util/pstl/test_utils.h: New file. * testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc: New file. * testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc: New file. * testsuite/20_util/specialized_algorithms/pstl/uninitialized_fill_destroy.cc: New file. * testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: New file. * testsuite/25_algorithms/pstl/alg_merge/merge.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/fill.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/generate.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/remove_copy.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/replace.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/swap_ranges.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/transform_binary.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/transform_unary.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc: New file. * testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/adjacent_find.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/for_each.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/mismatch.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc: New file. * testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: New file. * testsuite/25_algorithms/pstl/alg_sorting/includes.cc: New file. * testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: New file. * testsuite/25_algorithms/pstl/alg_sorting/is_sorted.cc: New file. * testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc: New file. * testsuite/25_algorithms/pstl/alg_sorting/minmax_element.cc: New file. * testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: New file. * testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc: New file. * testsuite/25_algorithms/pstl/alg_sorting/set.cc: New file. * testsuite/25_algorithms/pstl/alg_sorting/sort.cc: New file. * testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc: New file. * testsuite/26_numerics/pstl/numeric_ops/reduce.cc: New file. * testsuite/26_numerics/pstl/numeric_ops/scan.cc: New file. * testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc: New file. * testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: New file. * testsuite/testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc: New file. * testsuite/testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc: New file. * testsuite/testsuite/20_util/specialized_algorithms/pstl/uninitialized_fill_destroy.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_merge/merge.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/fill.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/generate.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/remove_copy.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/replace.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/swap_ranges.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/transform_binary.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/transform_unary.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/adjacent_find.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/for_each.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/mismatch.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_sorting/includes.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_sorting/is_sorted.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_sorting/minmax_element.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_sorting/set.cc: New file. * testsuite/testsuite/25_algorithms/pstl/alg_sorting/sort.cc: New file. * testsuite/testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc: New file. * testsuite/testsuite/26_numerics/pstl/numeric_ops/reduce.cc: New file. * testsuite/testsuite/26_numerics/pstl/numeric_ops/scan.cc: New file. * testsuite/testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc: New file. * testsuite/testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: New file. From-SVN: r269863
* In C++17 <math.h> should not put special functions in global namespaceJonathan Wakely2019-03-213-111/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IS 29124 8.2 [sf.mathh] says that <math.h> should add the names of the special functions to the global namespace. However, C++17 Annex D [depr.c.headers] excludes those functions explicitly, so they should not be placed in the global namespace unconditionally for C++17. Only add them to the global namespace when IS 29124 is explicitly requested via the __STDCPP_WANT_MATH_SPEC_FUNCS__ macro. * include/c_compatibility/math.h [!__STDCPP_WANT_MATH_SPEC_FUNCS__] (assoc_laguerre, assoc_laguerref, assoc_laguerrel, assoc_legendre) (assoc_legendref, assoc_legendrel, beta, betaf, betal, comp_ellint_1) (comp_ellint_1f, comp_ellint_1l, comp_ellint_2, comp_ellint_2f) (comp_ellint_2l, comp_ellint_3, comp_ellint_3f, comp_ellint_3l) (cyl_bessel_i, cyl_bessel_if, cyl_bessel_il, cyl_bessel_j) (cyl_bessel_jf, cyl_bessel_jl, cyl_bessel_k, cyl_bessel_kf) (cyl_bessel_kl, cyl_neumann, cyl_neumannf, cyl_neumannl, ellint_1) (ellint_1f, ellint_1l, ellint_2, ellint_2f, ellint_2l, ellint_3) (ellint_3f, ellint_3l, expint, expintf, expintl, hermite, hermitef) (hermitel, laguerre, laguerref, laguerrel, legendre, legendref) (legendrel, riemann_zeta, riemann_zetaf, riemann_zetal, sph_bessel) (sph_besself, sph_bessell, sph_legendre, sph_legendref, sph_legendrel) (sph_neumann, sph_neumannf, sph_neumannl): Only add using-declarations when the special functions IS is enabled, not for C++17. * testsuite/26_numerics/headers/cmath/functions_global_c++17.cc: Replace with ... * testsuite/26_numerics/headers/cmath/functions_global.cc: New test, without checks for special functions in C++17. * testsuite/26_numerics/headers/cmath/special_functions_global.cc: New test. From-SVN: r269837
* re PR libstdc++/89461 (FAIL: experimental/net/timer/waitable/cons.cc)John David Anglin2019-03-127-0/+25
| | | | | | | | | | | | | | PR libstdc++/89461 * testsuite/lib/libstdc++.exp: Locate libatomic. * testsuite/lib/dg-options.exp (add_options_for_libatomic): New. * testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc: Add libatomic options. * testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc: Likewise. * testsuite/experimental/net/timer/waitable/cons.cc: Likewise. * testsuite/experimental/net/timer/waitable/dest.cc: Likewise. * testsuite/experimental/net/timer/waitable/ops.cc: Likewise. From-SVN: r269628
* PR c++/86521 - wrong overload resolution with ref-qualifiers.Jason Merrill2019-03-111-2/+4
| | | | | | | | | | Here we were wrongly treating binding a const lvalue ref to an xvalue as direct binding, which is wrong under [dcl.init.ref] and [over.match.ref]. * call.c (build_user_type_conversion_1): Don't use a conversion to a reference of the wrong rvalueness for direct binding. From-SVN: r269602
* Change test to use const variables instead of macrosJonathan Wakely2019-03-111-2/+2
| | | | | | | | | This is C++ so there's no reason to use macros here. * testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc: Use const variables instead of macros. From-SVN: r269585
* PR libstdc++/89629 fix _Hash_bytes for lengths > INT_MAXJonathan Wakely2019-03-111-0/+43
| | | | | | | | | PR libstdc++/89629 * libsupc++/hash_bytes.cc [__SIZEOF_SIZE_T__ == 8] (_Hash_bytes): Use correct type for len_aligned. * testsuite/20_util/hash/89629.cc: New test. From-SVN: r269584
* re PR libstdc++/89608 (Undetected iterator invalidations on unordered ↵François Dumont2019-03-081-0/+37
| | | | | | | | | | | | | | | | | containers in debug mode) 2019-03-08 François Dumont <fdumont@gcc.gnu.org> PR libstdc++/89608 * include/debug/unordered_map (unordered_map<>::_M_check_rehashed): Invalidate all iterators in case of rehash. (unordered_multimap<>::_M_check_rehashed): Likewise. * include/debug/unordered_set (unordered_set<>::_M_check_rehashed): Likewise. (unordered_multiset<>::_M_check_rehashed): Likewise. * testsuite/23_containers/unordered_set/debug/89608_neg.cc: New. From-SVN: r269478
* Fix new test to run as well as compileJonathan Wakely2019-03-071-2/+2
| | | | | | | * testsuite/20_util/function_objects/bind_front/1.cc: Change from compile test to run. Fix typo. From-SVN: r269457
* P0356R5 Simplified partial function applicationJonathan Wakely2019-03-071-0/+176
| | | | | | | | | * include/std/functional [C++20] (_Bind_front, _Bind_front_t): Define helpers for bind_front. (bind_front, __cpp_lib_bind_front): Define. * testsuite/20_util/function_objects/bind_front/1.cc: New test. From-SVN: r269455
* Add feature test macro for bounded array traitsJonathan Wakely2019-03-062-0/+12
| | | | | | | | | * include/std/type_traits (__cpp_lib_bounded_array_traits): Define. * include/std/version (__cpp_lib_bounded_array_traits): Likewise. * testsuite/20_util/is_bounded_array/value.cc: Check for macro. * testsuite/20_util/is_unbounded_array/value.cc: Likewise. From-SVN: r269426
* PR libstdc++/86655 - std::assoc_legendre should not constrainEdward Smith-Rowland2019-03-064-0/+224
| | | | | | | | | | | | | | | | | | 2019-03-06 Edward Smith-Rowland <3dw4rd@verizon.net> PR libstdc++/86655 - std::assoc_legendre should not constrain the value of m (or x). * include/tr1/legendre_function.tcc (__assoc_legendre_p, __sph_legendre): If degree > order Don't throw, return 0. (__legendre_p, __assoc_legendre_p): Don't constrain x either. * testsuite/special_functions/02_assoc_legendre/pr86655.cc: New test. * testsuite/special_functions/20_sph_legendre/pr86655.cc: New test. * testsuite/tr1/5_numerical_facilities/special_functions/ 02_assoc_legendre/pr86655.cc: New test. * testsuite/tr1/5_numerical_facilities/special_functions/ 22_sph_legendre/pr86655.cc: New test. From-SVN: r269423
* Rewrite variant, also PR libstdc++/85517Ville Voutilainen2019-03-062-4/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * include/std/variant (__do_visit): New. (__variant_cast): Likewise. (__variant_cookie): Likewise. (__erased_*): Remove. (_Variant_storage::_S_vtable): Likewise. (_Variant_storage::__M_reset_impl): Adjust to use __do_visit. (_Variant_storage::__M_reset): Adjust. (__variant_construct): New. (_Copy_ctor_base(const _Copy_ctor_base&)): Adjust to use __variant_construct. (_Move_ctor_base(_Move_ctor_base&&)): Likewise. (_Move_ctor_base::__M_destructive_copy): New. (_Move_ctor_base::__M_destructive_move): Adjust to use __variant_construct. (_Copy_assign_base::operator=): Adjust to use __do_visit. (_Copy_assign_alias): Adjust to check both copy assignment and copy construction for triviality. (_Move_assign_base::operator=): Adjust to use __do_visit. (_Multi_array): Add support for visitors that accept and return a __variant_cookie. (__gen_vtable_impl::_S_apply_all_alts): Likewise. (__gen_vtable_impl::_S_apply_single_alt): Likewise. (__gen_vtable_impl::__element_by_index_or_cookie): New. Generate a __variant_cookie temporary for a variant that is valueless and.. (__gen_vtable_impl::__visit_invoke): ..adjust here. (__gen_vtable::_Array_type): Conditionally make space for the __variant_cookie visitor case. (__variant_construct_by_index): New. (get_if): Adjust to use std::addressof. (relops): Adjust to use __do_visit. (variant): Add __variant_cast and __variant_construct_by_index as friends. (variant::emplace): Use _M_reset() and __variant_construct_by_index instead of self-destruction. (variant::swap): Adjust to use __do_visit. (visit): Reimplement in terms of __do_visit. (__variant_hash_call_base_impl::operator()): Adjust to use __do_visit. * testsuite/20_util/variant/compile.cc: Adjust. * testsuite/20_util/variant/run.cc: Likewise. From-SVN: r269422
* Add L suffix to __cpp_lib_char8_t valueJonathan Wakely2019-03-061-2/+2
| | | | | | | | * include/bits/c++config.h (_cpp_lib_char8_t): Add L suffix to constant. * testsuite/experimental/feat-char8_t.cc: Likewise. From-SVN: r269421
* Add C++20 Traits for [Un]bounded Arrays (P1357R1)Jonathan Wakely2019-03-066-0/+259
| | | | | | | | | | | | | | | | | | * include/std/type_traits [C++20] (is_bounded_array) (is_unbounded_array, is_bounded_array_v, is_unbounded_array_v): Define. * testsuite/20_util/is_bounded_array/requirements/ explicit_instantiation.cc: New test. * testsuite/20_util/is_bounded_array/requirements/typedefs.cc: New test. * testsuite/20_util/is_bounded_array/value.cc: New test. * testsuite/20_util/is_unbounded_array/requirements/ explicit_instantiation.cc: New test. * testsuite/20_util/is_unbounded_array/requirements/typedefs.cc: New * test. * testsuite/20_util/is_unbounded_array/value.cc: New test. From-SVN: r269420
* Constexpr in std::pointer_traits (P1006R1)Jonathan Wakely2019-03-061-0/+27
| | | | | | | | * include/bits/ptr_traits.h [C++20] (pointer_traits<T*>::pointer_to): Add constexpr. * testsuite/20_util/pointer_traits/pointer_to_constexpr.cc: New test. From-SVN: r269418
* Define midpoint and lerp functions for C++20 (P0811R3)Jonathan Wakely2019-03-054-0/+372
| | | | | | | | | | | | | | | | | | | | | | | | | The implementation of midpoint used for integral types is due to Howard Hinnant and avoids a branch for int and larger types (but not for chars and shorts). The midpoint and lerp functions for floating point types come straight from the P0811R3 proposal, with no attempt at optimization. * include/c_compatibility/math.h [C++20] (lerp): Add using declaration. * include/c_global/cmath [C++20] (__cpp_lib_interpolate): Define. (__lerp): Define function template to implement lerp. (lerp(float, float, float), lerp(double, double, double)) (lerp(long double, long double, long double)): Define for C++20. * include/std/numeric [C++20] (__cpp_lib_interpolate): Define. (midpoint(T, T), midpoint(T*, T*)): Define. * include/std::version [C++20] (__cpp_lib_interpolate): Define. * testsuite/26_numerics/lerp.cc: New test. * testsuite/26_numerics/midpoint/floating.cc: New test. * testsuite/26_numerics/midpoint/integral.cc: New test. * testsuite/26_numerics/midpoint/pointer.cc: New test. From-SVN: r269398
* PR libstdc++/88996 Implement P0439R0Edward Smith-Rowland2019-03-042-0/+65
| | | | | | | | | | | | | 2019-03-04 Edward Smith-Rowland <3dw4rd@verizon.net> PR libstdc++/88996 Implement P0439R0 Make std::memory_order a scoped enumeration. * include/bits/atomic_base.h: For C++20 make memory_order a scoped enum, add variables for the old enumerators. Adjust calls. * testsuite/29_atomics/headers/atomic/types_std_c++2a.cc: New test. * testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc: New test. From-SVN: r269372