[PATCH] [libc++] Try and prevent evaluation of `is_default_constructible` on tuples default constructor if it is not needed.

Louis Dionne ldionne.2 at gmail.com
Wed Feb 11 15:45:30 PST 2015


The faulty code was mine. With the `pair` example, it is clear that all those `is_default_constructible<T>` are instantiated even when the default constructor is not. I think my intention when writing `Dummy && is_default_constructible<_Tp>::value` was to delay the instantiation of `is_default_constructible<_Tp>` as a compile-time optimization (which it fails to do), but not for correctness purposes.

However, looking at http://en.cppreference.com/w/cpp/types/is_default_constructible and then http://en.cppreference.com/w/cpp/concept/DefaultConstructible, I am unsure whether instantiating `is_default_constructible<_Tp>` should cause a hard error at all. If instantiating the default constructor in the expression

  
  _Tp x{}

causes a compile-time error, should `is_default_constructible<_Tp>::value` be false or trigger a compile-time error?

Summary: At a glance, the fix seems correct in that it will properly delay the instantiation of the `is_default_constructible<_Tp>`s. However, is there a bug in `is_default_constructible`?


http://reviews.llvm.org/D7569

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list