Init
This commit is contained in:
45
cppdraft/declval.md
Normal file
45
cppdraft/declval.md
Normal file
@@ -0,0 +1,45 @@
|
||||
[declval]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.2 Utility components [[utility]](utility#declval)
|
||||
|
||||
### 22.2.6 Function template declval [declval]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L508)
|
||||
|
||||
The library provides the function template declval to simplify the definition of
|
||||
expressions which occur as [unevaluated operands](expr.context#def:unevaluated_operand "7.2.3 Context dependence [expr.context]")[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:declval)
|
||||
|
||||
`template<class T> add_rvalue_reference_t<T> declval() noexcept; // as unevaluated operand
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L518)
|
||||
|
||||
*Mandates*: This function is not odr-used ([[basic.def.odr]](basic.def.odr#term.odr.use "6.3 One-definition rule"))[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L522)
|
||||
|
||||
*Remarks*: The template parameter T of declval may be an incomplete type[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L526)
|
||||
|
||||
[*Example [1](#example-1)*:
|
||||
|
||||
template<class To, class From> decltype(static_cast<To>(declval<From>())) convert(From&&); declares a function template convert which only participates in overload resolution if the
|
||||
type From can be explicitly converted to type To[.](#4.sentence-1)
|
||||
|
||||
For another example see class
|
||||
template common_type ([[meta.trans.other]](meta.trans.other "21.3.9.7 Other transformations"))[.](#4.sentence-2)
|
||||
|
||||
â *end example*]
|
||||
Reference in New Issue
Block a user