Namespaces
Variants
Views
Actions

std::declval

From cppreference.com
< cpp‎ | utility
Revision as of 13:08, 11 October 2011 by P12bot (Talk | contribs)

Template:cpp/utility/sidebar Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <utility>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td >
template <class T>
typename std::add_rvalue_reference<T>::type declval();
</td>

<td class="t-dcl-nopad"> </td> <td > Template:mark c++11 feature </td> </tr> Template:ddcl list end

Converts any type T to a reference type, making it possible to use member functions in Template:cpp expressions without specifying constructors. It is commonly used in templates where acceptable template parameters may have no constructor in common, but have the same member function whose return type is needed. Template:cpp can only be used in unevaluated contexts, it is an error to evaluate an expression that contains this function.

Contents

Parameters

(none)

Return value

Cannot be called, thus never returns a value, but the return type is T&& unless T is a reference type, in which case T& is returned.

Exceptions

noexcept specification:  
noexcept
  

Example

Template:example cpp

See also

Template:cpp/keywords/dcl list decltype
(C++11)(removed in C++20)(C++17)
deduces the result type of invoking a callable object with a set of arguments
(class template) [edit]