You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr
Eric Fiselier da1818a08c [libc++] Try and prevent evaluation of `is_default_constructible` on tuples 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@230120 91177308-0d34-0410-b5e6-96231b3b80d8
11 years ago
..
UTypes.fail.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
UTypes.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
alloc.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
alloc_UTypes.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
alloc_const_Types.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
alloc_const_pair.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
alloc_convert_copy.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
alloc_convert_move.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
alloc_copy.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
alloc_move.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
alloc_move_pair.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
const_Types.fail.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
const_Types.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
const_Types2.fail.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
const_pair.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
convert_copy.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
convert_move.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
copy.fail.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
copy.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
default.pass.cpp [libc++] Try and prevent evaluation of `is_default_constructible` on tuples default constructor if it is not needed. 11 years ago
move.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
move_pair.pass.cpp [libcxx] Mark most tuple tests UNSUPPORTED for c++03 and c++98. 11 years ago
tuple_array_template_depth.pass.cpp Mark more tuple tests as unsupported in C++98 && C++03 11 years ago