C++ Logo

sg10

Advanced search

Re: [SG10] __cpp_variadic_using for p0195r2?

From: Richard Smith <richard_at_[hidden]>
Date: Mon, 19 Dec 2016 23:30:47 -0800
On 19 December 2016 at 14:48, John Spicer <jhs_at_[hidden]> wrote:

>
> On Dec 19, 2016, at 5:27 PM, Richard Smith <richard_at_[hidden]> wrote:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0195r2.html
> suggests a feature test macro of __cpp_variadic_using; the value would
> presumably be 201611. Does that seem OK to everyone?
>
>
> I think it is okay.
>
> I think it is slightly odd as the change is to allow multiple names in a
> using-declaration, but the expected use case is for variadics.
>
> I’d also be okay with something like __cpp_multi_using.
>
> __cpp_variadic_using had more support when it was discussed in core, FWIW.
>

I don't see any reason you'd want to feature test for the
multiple-names-in-one-using-declaration part of the feature -- just don't
use them if you want to be compatible with old language modes. But the
variadic part does seem like something people would want to feature-test
for. I can imagine someone wanting to write:

#if __cpp_variadic_using >= 201611
template<typename ...T> struct Callable : T... {
  using T::operator() ...;
};
#else
template<typename ...T> struct Callable;
template<typename T, typename ...U> struct Callable<T, U...> : T,
Callable<U...> {
  using T::operator();
  using Callable<U...>::operator();
};
template<typename T> struct Callable<T> : T {
  using T::operator();
};
template<> struct Callable<> {};
#endif

Received on 2016-12-20 08:31:08