CARVIEW |
Select Language
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Fri, 25 Jul 2025 14:38:20 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Location: /reference/functional/function/target_type/
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 25 Jul 2025 14:38:20 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"9b12-IixSxtHRES+jXbYlpMWoEBL6GOE"
Content-Encoding: gzip
Returns the type_info object that identifies the type of the target.
The function returns the same as applying the
If the object has no target (i.e., it is an empty function), this function returns
Note that a single type instantiation of function is able to hold different target types with the same calling signatures: for example, the same function object may hold a pointer to a function or a function object.
type_info is a type defined in header <typeinfo> that can be used to compare types.
Output:
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<functional>
functions
wrapper classes
- binary_negate
-
functionC++11
-
reference_wrapperC++11
- unary_negate
operator classes
other classes
-
bad_function_callC++11
-
hashC++11
-
is_bind_expressionC++11
-
is_placeholderC++11
-
namespaces
-
placeholdersC++11
-
deprecated
function
-
function::~functionC++11
-
function::functionC++11
member functions
-
function::assignC++11
-
function::operator boolC++11
-
function::operator()C++11
-
function::operator=C++11
-
function::swapC++11
-
function::targetC++11
-
function::target_typeC++11
-
non-member overloads
-
relational operators (function)C++11
-
swap (function)C++11
-
- Reference
- <functional>
- function
- target_type
public member function
<functional>
std::function::target_type
const type_info& target_type() const noexcept;
Target type_info
The function returns the same as applying the
typeid
operator to the type of the callable object used as target.If the object has no target (i.e., it is an empty function), this function returns
typeid(void)
.Note that a single type instantiation of function is able to hold different target types with the same calling signatures: for example, the same function object may hold a pointer to a function or a function object.
Parameters
noneReturn value
The type_info object that corresponds to the type of the target, ortypeid(void)
if the object is an empty function.type_info is a type defined in header <typeinfo> that can be used to compare types.
Example
|
|
Output:
pointers as targets: plus1 : true plus2 : false minus1: true minus2: false same type?: (plus1, plus2) : false (minus1,minus2): false (plus1, minus1): true (plus2, minus2): false |
Data races
The object is accessed.Exception safety
No-throw guarantee: this member function never throws exceptions.See also
- function::target
- Get pointer to target (public member function)
- function::operator bool
- Check if callable (public member function)
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us