Files
cppdraft_translate/cppdraft/declval.md
2025-10-25 03:02:53 +03:00

1.6 KiB

[declval]

22 General utilities library [utilities]

22.2 Utility components [utility]

22.2.6 Function template declval [declval]

1

#

The library provides the function template declval to simplify the definition of expressions which occur as unevaluated operands.

🔗

template<class T> add_rvalue_reference_t<T> declval() noexcept; // as unevaluated operand

2

#

Mandates: This function is not odr-used ([basic.def.odr]).

3

#

Remarks: The template parameter T of declval may be an incomplete type.

4

#

[Example 1:

template<class To, class From> decltype(static_cast(declval())) convert(From&&); declares a function template convert which only participates in overload resolution if the type From can be explicitly converted to type To.

For another example see class template common_type ([meta.trans.other]).

— end example]