C++ Logo

std-proposals

Advanced search

Fwd: p1858r0 Generalized pack, disambiguation, alias to nttp and ttp

From: Cleiton Santoia Silva <cleitonsantoia_at_[hidden]>
Date: Tue, 19 Nov 2019 23:17:47 -0300
||1 - Today, disambiguation between type name or template name is done
thru ||||||prefixing ||keywords like "typename" or "template"||
||||

||template<typename T> void bar() { S<T> s; ||||||typename S<T>::Int x; || s.template foo<T>(); }||


Inp1858r0 <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/phttp://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1858r0.htmlr0.html> at session 2.6

|have you considered "template..." ( template dot dot dot ) as
disambiguation token ? |
|template <typename Tuple> int tuple_sum(Tuple t) { |||return sum( t.||||||template... ||elems); |} |
2 - Have you thought on alias to variadic template template parameters ?

template<template<typename, typename> typename ... C >
struct X {
    using ...D = C;
};

X<std::vector, std::list>::D...; // <- this is a variadic template template variadic argument list <std::vector, std::list>


3 - And about alias to variadic non type template parameters ?

template<int ... ints>
struct X {
    static constexpr auto ...Ints = ints.[:]; // maybe ?
};

int x[] = { X<78, 90, 60>::Ints... }; // <- this is a variadic list of integers

3.1 - Can I apply a transform on each element ?

template<int ... ints>
struct X {
    static constexpr auto ...Ints = ints.[:] + 1; // Apply a transform Int.[x] = ints.[x] + 1
};

int x[] = { X<78, 90, 60>::Ints... }; // <- this is a variadic list of integers x = { 79, 91, 61 }
int x[] = {(X<5, 10, 15>::Ints * 2)... }; // <- this is a variadic list of integers x = { 12, 22, 32 }


  

BR
Cleiton


Received on 2019-11-19 20:20:10