C++ Logo

sg10

Advanced search

Re: [SG10] Updated SD-6 draft

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Thu, 4 Aug 2016 13:28:21 +0100
Example for P0013R1 __cpp_lib_logical_traits

template<typename... T>
  using condition =
#if __cpp_lib_logical_traits
  conjunction<is_pointer<decay_t<T>>...>;
#else
  bool_constant<(is_pointer<decay_t<T>>::value && ...)>;
#endif

template<typename... T>
  enable_if_t<condition<T...>::value>
  foo(T&&...) { }

template<typename... T>
  enable_if_t<!condition<T...>::value>
  foo(T&&...) { }

Using conjunction is more efficient at compile-time, because it short
circuits and doesn't evaluate every expression in the pack expansion
if it doesn't need to.

Received on 2016-08-04 14:28:43