The std::declval Type Operator

Discover the capabilities and usage of the std::declval type operator in C++ metaprogramming.

The std::declval is a utility type operation function, available in the <utility> header. It’s in the same category as functions such as std::move and std::forward that we have already seen. What it does is very simple: it adds an rvalue reference to its type template argument. The declaration of this function looks as follows:

Get hands-on with 1400+ tech skills courses.