summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/tuple
Commit message (Collapse)AuthorAgeFilesLines
...
* [libcxx] Re-implement LWG 2770 again: Fix tuple_size to work with structured ↵Eric Fiselier2017-01-045-18/+307
| | | | | | | | | | | | | | | | | | | bindings Summary: This patch attempts to re-implement a fix for LWG 2770, but not the actual specified PR. The PR for 2770 specifies tuple_size<T const> as only conditionally providing a `::value` member. However C++17 structured bindings require `tuple_size<T const>` to be complete only if `tuple_size<T>` is also complete. Therefore this patch implements only provides the specialization `tuple_size<T CV>` iff `tuple_size<T>` is a complete type. This fixes http://llvm.org/PR31513. Reviewers: mclow.lists, rsmith, mpark Subscribers: mpark, cfe-commits Differential Revision: https://reviews.llvm.org/D28222 llvm-svn: 291019
* Re-implement LWG 2770 - Fix tuple_size with structured bindings.Eric Fiselier2017-01-023-24/+16
| | | | | | | This patch implements the correct PR for LWG 2770. It also makes the primary tuple_size template incomplete again which fixes part of llvm.org/PR31513. llvm-svn: 290846
* Fix unused parameters and variablesEric Fiselier2016-12-234-8/+11
| | | | llvm-svn: 290459
* Fix XFAILS for is_trivially_destructible traitEric Fiselier2016-12-151-3/+0
| | | | llvm-svn: 289802
* Add tests for LWG 2796Eric Fiselier2016-12-151-0/+38
| | | | llvm-svn: 289780
* Add more test cases for PR31384Eric Fiselier2016-12-151-9/+59
| | | | llvm-svn: 289778
* Add test case for PR31384Eric Fiselier2016-12-151-0/+38
| | | | llvm-svn: 289774
* Revert r289727 due to PR31384Eric Fiselier2016-12-152-269/+0
| | | | | | | | This patch reverts the changes to tuple which fixed construction from types derived from tuple. It breaks the code mentioned in llvm.org/PR31384. I'll follow this commit up with a test case. llvm-svn: 289773
* Work around bug in initialization of std::array base class with older clangsEric Fiselier2016-12-142-3/+9
| | | | llvm-svn: 289741
* [libcxx] Fix tuple construction/assignment from types derived from ↵Eric Fiselier2016-12-142-0/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tuple/pair/array. Summary: The standard requires tuple have the following constructors: ``` tuple(tuple<OtherTypes...> const&); tuple(tuple<OtherTypes...> &&); tuple(pair<T1, T2> const&); tuple(pair<T1, T2> &&); tuple(array<T, N> const&); tuple(array<T, N> &&); ``` However libc++ implements these as a single constructor with the signature: ``` template <class TupleLike, enable_if_t<__is_tuple_like<TupleLike>::value>> tuple(TupleLike&&); ``` This causes the constructor to reject types derived from tuple-like types; Unlike if we had all of the concrete overloads, because they cause the derived->base conversion in the signature. This patch fixes this issue by detecting derived types and the tuple-like base they are derived from. It does this by creating an overloaded function with signatures for each of tuple/pair/array and checking if the possibly derived type can convert to any of them. This patch fixes [PR17550]( https://llvm.org/bugs/show_bug.cgi?id=17550) This patch Reviewers: mclow.lists, K-ballo, mpark, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27606 llvm-svn: 289727
* [libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, ↵Stephan T. Lavavej2016-12-092-7/+6
| | | | | | | | | | | | | | | | | | | | | | remove an unused variable. test/support/test_macros.h For convenience/greppability, add macros for libcxx-specific static_asserts about noexceptness. (Moving the definitions of ASSERT_NOEXCEPT/ASSERT_NOT_NOEXCEPT isn't technically necessary because they're macros, but I think it's better style to define stuff before using it.) test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp There was a completely unused `TrackedCallable obj;`. apply() isn't depicted with conditional noexcept in C++17. test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp Now that we have LIBCPP_ASSERT_NOEXCEPT, use it. Fixes D27622. llvm-svn: 289264
* Fix PR27374 - Remove the implicit reduced-arity-extension in tuple.Eric Fiselier2016-12-081-7/+14
| | | | | | | | | | | | | | | | | | | This patch removes libc++'s tuple extension which allowed it to be constructed from fewer initializers than elements; with the remaining elements being default constructed. However the implicit version of this extension breaks conforming code. For example: int fun(std::string); int fun(std::tuple<std::string, int>); int x = fun("hello"); // ambigious Because existing code may already depend on this extension it can be re-enabled by defining _LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION. Note that the explicit version of this extension is still supported, although it's somewhat less useful than the implicit one. llvm-svn: 289158
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-0810-85/+85
| | | | | | | | | | | | | | | | | | | | | loss of data", part 5/7. Instead of storing double in double and then truncating to int, store int in long and then widen to long long. This preserves test coverage (as these tests are interested in various tuple conversions) while avoiding truncation warnings. test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp Since we aren't physically truncating anymore, t1 is equal to p0. test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp One edit is different from the usual pattern. Previously, we were storing double in double and then converting to A, which has an implicitly converting constructor from int. Now, we're storing int in int and then converting to A, avoiding the truncation. Fixes D27542. llvm-svn: 289109
* [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible ↵Stephan T. Lavavej2016-12-082-55/+55
| | | | | | | | | | | loss of data", part 4/7. Change char to long and remove some char casts. This preserves test coverage for tuple's heterogeneous comparisons, while avoiding int-to-char truncation warnings. Fixes D27541. llvm-svn: 289108
* [libcxx] [test] D27266: Remove spurious semicolons.Stephan T. Lavavej2016-12-061-1/+1
| | | | llvm-svn: 288750
* Implement LWG 2770 - Make tuple_size<T> defined for all TEric Fiselier2016-11-133-4/+30
| | | | llvm-svn: 286779
* Fix PR30979 - tuple<move_only> is constructible from move_only const&Eric Fiselier2016-11-131-0/+50
| | | | llvm-svn: 286774
* [libcxx] [test] Replace _LIBCPP_STD_VER with TEST_STD_VER.Stephan T. Lavavej2016-11-0414-17/+40
| | | | | | | | | | | This replaces every occurrence of _LIBCPP_STD_VER in the tests with TEST_STD_VER. Additionally, for every affected file, #include "test_macros.h" is being added explicitly if it wasn't already there. https://reviews.llvm.org/D26294 llvm-svn: 286007
* Make make_from_tuple tests more portable. Patch from STL@microsoft.comEric Fiselier2016-10-231-4/+4
| | | | llvm-svn: 284943
* Add missing <memory> include in testEric Fiselier2016-10-081-0/+1
| | | | llvm-svn: 283633
* Recommit r276548 - Make pair/tuples assignment operators SFINAE properly.Eric Fiselier2016-07-252-0/+118
| | | | | | | I think I've solved issues with is_assignable and references to incomplete types. The updated patch adds tests for this case. llvm-svn: 276603
* Revert r276548 - Make pair/tuples assignment operators SFINAE properly.Eric Fiselier2016-07-252-118/+0
| | | | | | | | | | | | This is a breaking change. The SFINAE required is instantiated the second the class is instantiated, and this can cause hard SFINAE errors when applied to references to incomplete types. Ex. struct IncompleteType; extern IncompleteType it; std::tuple<IncompleteType&> t(it); // SFINAE will blow up. llvm-svn: 276598
* Fix MSVC unreferenced parameter warning. Patch from STL@microsoft.comEric Fiselier2016-07-241-1/+1
| | | | llvm-svn: 276583
* Make pair/tuples assignment operators SFINAE properly.Eric Fiselier2016-07-242-0/+118
| | | | llvm-svn: 276548
* Suppress warning in make_from_tuple tests.Eric Fiselier2016-07-181-0/+4
| | | | llvm-svn: 275748
* Implement C++17 tuple bits. Including apply and make_from_tuple.Eric Fiselier2016-07-187-0/+1151
| | | | | | | | | | This patch upgrades <tuple> to be C++17 compliant by implementing: * tuple_size_v: This was forgotten when implementing the other _v traits. * std::apply: This was added via LFTS v1 in p0220r1. * std::make_from_tuple: This was added in p0209r2. llvm-svn: 275745
* Handle std::get<T>(...) for std::tuple<>Eric Fiselier2016-07-021-0/+3
| | | | llvm-svn: 274422
* Rewrite std::get<Type>(...) helper using constexpr functions.Eric Fiselier2016-07-025-92/+35
| | | | llvm-svn: 274418
* Cleanup SFINAE in tuple, and add tests for reference assignmentEric Fiselier2016-07-022-0/+31
| | | | llvm-svn: 274414
* Make tuple_constructible and family lazy again.Eric Fiselier2016-07-021-0/+102
| | | | llvm-svn: 274413
* Flatten the tuple_element and __make_tuple_types implementations.Eric Fiselier2016-07-011-0/+34
| | | | | | | | | | This patch attempts to improve the QoI of std::tuples tuple_element and __make_tuple_types helpers. Previously they required O(N) instantiations, one for every element in the tuple The new implementations are O(1) after __tuple_indices<Id...> is created. llvm-svn: 274330
* Move remaining _LIBCPP_VERSION tests into test/libcxxEric Fiselier2016-06-221-20/+0
| | | | llvm-svn: 273367
* Fix comment typos, strip trailing whitespace. Patch from STL@microsoft.comEric Fiselier2016-06-221-2/+2
| | | | llvm-svn: 273357
* Fix PR27684 - std::tuple no longer accepts reference to incomplete type in ↵Eric Fiselier2016-06-212-20/+56
| | | | | | | | | | | | | | | | | some cases. Libc++ has to deduce the 'allocator_arg_t' parameter as 'AllocArgT' for the following constructor: template <class Alloc> tuple(allocator_arg_t, Alloc const&) Previously libc++ has tried to support tags derived from 'allocator_arg_t' by using 'is_base_of<AllocArgT, allocator_arg_t>'. However this breaks whenever a 2-tuple contains a reference to an incomplete type as its first parameter. See https://llvm.org/bugs/show_bug.cgi?id=27684 llvm-svn: 273334
* Fix warning in tuple tests. The test suite should now run clean with most ↵Eric Fiselier2016-06-151-8/+3
| | | | | | warnings enabled llvm-svn: 272822
* Replace __cplusplus comparisons and dialect __has_feature checks with ↵Eric Fiselier2016-06-142-2/+6
| | | | | | | | | TEST_STD_VER. This is a huge cleanup that helps make the libc++ test suite more portable. Patch from STL@microsoft.com. Thanks STL! llvm-svn: 272716
* Remove trailing whitespace in test suite. Approved by Marshall Clow.Eric Fiselier2016-06-0111-13/+13
| | | | llvm-svn: 271435
* [libcxx] Improve tests to use the UNSUPPORTED lit directiveAsiri Rathnayake2016-05-284-16/+0
| | | | | | | | | | | | | | | | | | | Quite a few libcxx tests seem to follow the format: #if _LIBCPP_STD_VER > X // Do test. #else // Empty test. #endif We should instead use the UNSUPPORTED lit directive to exclude the test on earlier C++ standards. This gives us a more accurate number of test passes for those standards and avoids unnecessary conflicts with other lit directives on the same tests. Reviewers: bcraig, ericwf, mclow.lists Differential revision: http://reviews.llvm.org/D20730 llvm-svn: 271108
* Guard testing of tuple extensions to make tests portableEric Fiselier2016-05-275-2/+16
| | | | llvm-svn: 271065
* Remove names of unreferenced parameters. Patch from STL@microsoft.comEric Fiselier2016-04-281-2/+2
| | | | llvm-svn: 267852
* Fix some non-standard parts of our test suite. Reported by STLEric Fiselier2016-04-221-0/+1
| | | | llvm-svn: 267131
* Make tuples constructors conditionally EXPLICIT. See N4387Eric Fiselier2016-04-1911-3/+285
| | | | llvm-svn: 266703
* Cleanup and guard tuple's constructor SFINAE. Fixes PR22806 and PR23256.Eric Fiselier2016-04-153-2/+278
| | | | | | | | | | | | | | | | | | | | | There are two main fixes in this patch. First the constructor SFINAE was changed so that it's evaluated in two stages where the first stage evaluates the "safe" SFINAE conditions and the second evaluates the "dangerous" ones. The key is that the second stage is lazily evaluated only if the first stage passes. This helps fix PR23256 (https://llvm.org/bugs/show_bug.cgi?id=23256). The second fix is for PR22806 and LWG issue 2549. This fix applies the suggested resolution to the LWG issue in order to prevent the construction of dangling references. The SFINAE for this check is contained within the _PreferTupleLikeConstructor alias template. The tuple-like constructors are disabled whenever that trait returns false. (https://llvm.org/bugs/show_bug.cgi?id=22806) (http://cplusplus.github.io/LWG/lwg-active.html#2549) llvm-svn: 266461
* [libcxx] Remove the "reduced-arity-initialization" extension from the ↵Eric Fiselier2016-04-152-55/+98
| | | | | | | | | | | | | | | | | uses-allocator constructors Summary: A default uses-allocator constructor has been added since that overload was previously provided by the extended constructor. Since Clang does implicit conversion checking after substitution this constructor has to deduce the allocator_arg_t parameter so that it can prevent the evaluation of "is_default_constructible" if the first argument doesn't match. See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1391 for more information. This patch fixes PR24779 (https://llvm.org/bugs/show_bug.cgi?id=24779) Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19006 llvm-svn: 266409
* Fix type in tuple test. Sorry for the noiseEric Fiselier2015-12-181-2/+2
| | | | llvm-svn: 255944
* [libcxx] LWG2485: get() should be overloaded for const tuple&&. Patch from ↵Eric Fiselier2015-12-183-6/+153
| | | | | | | K-Ballo. Review: http://reviews.llvm.org/D14839 llvm-svn: 255941
* [libc++] Try and prevent evaluation of `is_default_constructible` on tuples ↵Eric Fiselier2015-02-211-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | default constructor if it is not needed. Summary: Currently parts of the SFINAE on tuples default constructor always gets evaluated even when the default constructor is never called or instantiated. This can cause a hard compile error when a tuple is created with types that do not have a default constructor. Below is a self contained example using a pair like class. This code will not compile but probably should. ``` #include <type_traits> template <class T> struct IllFormedDefaultImp { IllFormedDefaultImp(T x) : value(x) {} constexpr IllFormedDefaultImp() {} T value; }; typedef IllFormedDefaultImp<int &> IllFormedDefault; template <class T, class U> struct pair { template <bool Dummy = true, class = typename std::enable_if< std::is_default_constructible<T>::value && std::is_default_constructible<U>::value && Dummy>::type > constexpr pair() : first(), second() {} pair(T const & t, U const & u) : first(t), second(u) {} T first; U second; }; int main() { int x = 1; IllFormedDefault v(x); pair<IllFormedDefault, IllFormedDefault> p(v, v); } ``` One way to fix this is to use `Dummy` in a more involved way in the constructor SFINAE. The following patch fixes these sorts of hard compile errors for tuple. Reviewers: mclow.lists, rsmith, K-ballo, EricWF Reviewed By: EricWF Subscribers: ldionne, cfe-commits Differential Revision: http://reviews.llvm.org/D7569 llvm-svn: 230120
* Mark more tuple tests as unsupported in C++98 && C++03Eric Fiselier2015-02-192-0/+4
| | | | llvm-svn: 229810
* [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98.Eric Fiselier2015-02-1952-12/+103
| | | | | | | | | | | | | | Summary: No declaration for the type `tuple` is given in c++03 or c++98 modes. Mark all tests that use the actual `tuple` type as UNSUPPORTED. Reviewers: jroelofs, mclow.lists, danalbert Reviewed By: danalbert Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5956 llvm-svn: 229808
* Get tests running with warnings. Fix warnings in headers and testsEric Fiselier2015-02-055-4/+18
| | | | llvm-svn: 228344
OpenPOWER on IntegriCloud