Home:ALL Converter>volatile and const volatile std::tuple and std::get

volatile and const volatile std::tuple and std::get

Ask Time:2014-11-11T06:37:05         Author:user4237465

Json Formatter

Looking at the C++11 standard. I can see that specialization of std::tuple_size and std::tuple_element are provided for volatile and const volatile tuple.

template <size_t I, class T> class tuple_element<I, volatile T>;
template <size_t I, class T> class tuple_element<I, const volatile T>;

template <class T> class tuple_size<volatile T>;
template <class T> class tuple_size<const volatile T>;

But std::get do no offer specialization for volatile or const volatile tuple.

I tried the following code on GCC.4.8.1

volatile std::tuple<int, int> a(1, 1);
std::cout << "a<0>=" << std::get<0>(a) << "\n";

I get error: no matching function for call to 'get(volatile std::tuple<int, int>&)'

So if I understand I can create (const) volatile tuples but I can not access their elements.

Is this an expected behavior or an oversight ?

Thanks very much.

Author:user4237465,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/26854320/volatile-and-const-volatile-stdtuple-and-stdget
yy