Commit Graph

27 Commits

Author SHA1 Message Date
Eric Fiselier 888d91a9e4 Move __lazy_* metafunctions to type traits and add tests
llvm-svn: 246408
2015-08-31 03:50:31 +00:00
Eric Fiselier 57f00f2f9c [libcxx] Move tuple_size and tuple_element overloads for pair and array out of !defined(_LIBCPP_HAS_NO_VARIADICS) block.
Summary:
There is no reason to guard `tuple_size`, `tuple_element` and `get<I>(...)` for pair and array inside of `<__tuple>` so that they are only available when we have variadic templates.
This requires there be redundant declarations and definitions. It also makes it easy to get things wrong.

For example the following code should compile (and does in c++11).
```
#define _LIBCPP_HAS_NO_VARIADICS
#include <array>

int main()
{
  static_assert((std::tuple_size<std::array<int, 10> volatile>::value == 10), "");
}
```

This patch lifts the non-variadic parts of `tuple_size`, `tuple_types`, and `get<I>(...)` to the top of `<__tuple>` where they don't require variadic templates. This patch also removes `<__tuple_03>` because there is no longer a need for it.


Reviewers: danalbert, K-ballo, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D7774

llvm-svn: 232492
2015-03-17 15:08:03 +00:00
Eric Fiselier 295bce1130 [libcxx] Delay evaluation of __make_tuple_types to prevent blowing the max template instantiation depth. Fixes Bug #18345
Summary:
http://llvm.org/bugs/show_bug.cgi?id=18345

Tuple's constructor and assignment operators for "tuple-like" types evaluates __make_tuple_types unnecessarily. In the case of a large array this can blow the template instantiation depth.

Ex:
```
#include <array>
#include <tuple>
#include <memory>
 
typedef std::array<int, 1256> array_t;
typedef std::tuple<array_t> tuple_t;

int main() {
  array_t a;
  tuple_t t(a); // broken
  t = a; // broken

  // make_shared uses tuple behind the scenes. This bug breaks this code.
  std::make_shared<array_t>(a);
}
```

To prevent this from happening we delay the instantiation of `__make_tuple_types` until after we perform the length check. Currently `__make_tuple_types` is instantiated at the same time that the length check .


Test Plan: Two tests have been added. One for the "tuple-like" constructors and another for the "tuple-like" assignment operator. 

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: K-ballo, cfe-commits

Differential Revision: http://reviews.llvm.org/D4467

llvm-svn: 220769
2014-10-28 06:31:22 +00:00
Eric Fiselier 567bb79bf2 D4451: Fix copy/move issues casude by __tuple_leafs's converting constructor
llvm-svn: 213888
2014-07-24 18:48:34 +00:00
Howard Hinnant f0544c2086 Nico Rieck: this patch series fixes visibility issues on Windows as explained in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-August/031214.html>.
llvm-svn: 188192
2013-08-12 18:38:34 +00:00
Marshall Clow 8bf1f08a2c Make std::get constexpr
llvm-svn: 186525
2013-07-17 18:25:36 +00:00
Howard Hinnant 6e41256f68 No functionality change at this time. I've split _LIBCPP_VISIBLE up into two flags: _LIBCPP_TYPE_VIS and _LIBCPP_FUNC_VIS. This is in preparation for taking advantage of clang's new __type_visibility__ attribute.
llvm-svn: 176593
2013-03-06 23:30:19 +00:00
Howard Hinnant aeb85680fb Dimitry Andric: many visibility fixes. Howard: Much appreciated. Can you send me a patch to CREDITS.TXT?
llvm-svn: 163862
2012-09-14 00:39:16 +00:00
Howard Hinnant 0527c6207a I believe tuple is still under development in the standard. Daniel Krugler is/will be making convincing arguments that a modified form of LWG 2051 (currently NAD Future) is easily acheivable and desirable. He has demonstrated that a tuple<T...> where all of the T are implicitly convertible from U... should have a tuple constructor that is also implicit, instead of explicit. This would support the use cases in LWG 2051 while not undermining T... with explicit conversions from U.... This check-in is an experimental implementation of Daniel's work. I believe this work to be mature enough to warrant inclusion into libc++. If anyone sees real-world problems that this check in causes, please let me know and I will revert it, and provide the feedback to the LWG.
llvm-svn: 153855
2012-04-01 23:10:42 +00:00
Howard Hinnant c206366fd7 Quash a whole bunch of warnings
llvm-svn: 145624
2011-12-01 20:21:04 +00:00
Howard Hinnant 073458b1ab Windows support by Ruben Van Boxem.
llvm-svn: 142235
2011-10-17 20:05:10 +00:00
Howard Hinnant b929de3c3d Changed constraints on pair and tuple constructors from is_convertible to is_constructible.
llvm-svn: 134252
2011-07-01 20:12:51 +00:00
Howard Hinnant 8f0cd597f1 noexcept for <array>.
llvm-svn: 132359
2011-05-31 21:06:33 +00:00
Howard Hinnant 27d0a2a75d noexcept for <tuple>. And in the process learned that I had done it wrong for pair's swap. I needed to create an __is_nothrow_swappable<T>::value trait that was smart enought to answer false when __is_swappable<T>::value is false. Otherwise one gets compile-time errors when using pair or tuple of non-swappable types, even if you never try to swap the pair or tuple.
llvm-svn: 132204
2011-05-27 19:08:18 +00:00
Howard Hinnant 8cad46266c I have to revert this recent fix to tuple conversions until clang implements cwg 1170. Without this fix pair and tuple don't convert properly. With it, associative containers get access errors when they shouldn't. cwg 1170 fixes the latter.
llvm-svn: 127411
2011-03-10 17:27:30 +00:00
Howard Hinnant b5d166ad93 Chris Jefferson found this bug to pair/tuple introduced by a recent change to the draft that I missed.
llvm-svn: 126743
2011-03-01 14:27:55 +00:00
Howard Hinnant 465abe92a5 Chandler Carruth changed >> to > > in several places.
llvm-svn: 124120
2011-01-24 16:07:25 +00:00
Howard Hinnant 7f64810bc8 LWG 1385 [FCD] tuple_cat should be a single variadic signature (http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#1385). This issue is only in Ready status, meaning it is not official, but probably will be this March in Madrid. It was tentatively accepted in Batavia with the previso that Bill and I didn't have any problems implementing it. This is my part of that agreement.
llvm-svn: 121619
2010-12-11 20:47:50 +00:00
Howard Hinnant 092980dd65 N3123
llvm-svn: 119906
2010-11-20 18:25:22 +00:00
Howard Hinnant 601afb30ec LWG 1191
llvm-svn: 119545
2010-11-17 19:52:17 +00:00
Howard Hinnant ef6168357a LWG 1118
llvm-svn: 119541
2010-11-17 19:22:43 +00:00
Howard Hinnant 412dbebe1b license change
llvm-svn: 119395
2010-11-16 22:09:02 +00:00
Howard Hinnant 30ad985b6b Cleaning up some tuple code.
llvm-svn: 114848
2010-09-27 17:54:17 +00:00
Howard Hinnant f5ab703f68 visibility-decoration.
llvm-svn: 114470
2010-09-21 20:16:37 +00:00
Howard Hinnant b3371f6f49 Fixing whitespace problems
llvm-svn: 111750
2010-08-22 00:02:43 +00:00
Howard Hinnant 5b08a8a432 Wiped out some non-ascii characters that snuck into the copyright.
llvm-svn: 103516
2010-05-11 21:36:01 +00:00
Howard Hinnant 3e519524c1 libcxx initial import
llvm-svn: 103490
2010-05-11 19:42:16 +00:00