Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 22574

Type trait that returns the template parameter of a template function

$
0
0

Suppose one has the following template function:

template<typename T>  auto foobar ()  {}

Question: is it possible to define a type trait that provides the template parameter of the function ?

If we call get_template_parameter such a trait, one could then write:

template<typename T>  auto foobar ()  {}using type = typename get_template_parameter <decltype(foobar<double>)>::type;static_assert (std::is_same_v<type,double>);

Viewing all articles
Browse latest Browse all 22574

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>