Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a alias of std::tuple?

Tags:

c++

std

tuples

I am learning C++ and I'd like to know how could create an alias for std::tuple.

I want to do what you might do with std::tuple but using another name. Is it possible?

Thanks.

like image 998
Juan Solo Avatar asked Jan 10 '23 23:01

Juan Solo


2 Answers

template <typename... Args>
using my_tuple = std::tuple<Args...>;

Live demo link.

like image 148
Piotr Skotnicki Avatar answered Jan 17 '23 15:01

Piotr Skotnicki


You can do that with template alias

template< class... tupleArgs > using newname = std::tuple< tupleArgs... >;

int main()
{
   newname<int, std::string, double> t1;
   return 0;
}

Simple demo

like image 41
Marco A. Avatar answered Jan 17 '23 15:01

Marco A.