1#ifndef MSTL_CORE_UTILITY_REFERENCE_WRAPPER_HPP__
2#define MSTL_CORE_UTILITY_REFERENCE_WRAPPER_HPP__
23template <
typename T,
typename U,
typename Dummy =
void>
24struct ref_wrapper_constructable_from :
false_type {};
26template <
typename T,
typename U>
27struct ref_wrapper_constructable_from<T, U,
void_t<
32template <
typename F,
typename... Args>
33struct __invoke_result_aux;
38template <
typename F,
typename... Args>
41template <
typename Callable,
typename... Args>
42MSTL_CONSTEXPR14
typename _INNER __invoke_result_aux<Callable, Args...>::type
43invoke(Callable&& f, Args&&... args)
65 "reference_wrapper requires an object or function type.");
83 _INNER ref_wrapper_constructable_from<T, U>>::value,
int> = 0>
86 T&
ref =
static_cast<U&&
>(x);
96 MSTL_CONSTEXPR14
operator T &()
const noexcept {
104 MSTL_NODISCARD MSTL_CONSTEXPR14 T&
get() const noexcept {
116 template <
typename... Args>
117 MSTL_CONSTEXPR14
typename _INNER __invoke_result_aux<T&, Args...>
::type
123#if MSTL_SUPPORT_DEDUCTION_GUIDES__
147void ref(
const T&&) =
delete;
MSTL_CONSTEXPR14 _INNER __invoke_result_aux< T &, Args... >::type operator()(Args &&... args) const noexcept(is_nothrow_invocable< T &, Args... >::value)
函数调用运算符
MSTL_CONSTEXPR14 reference_wrapper(U &&x) noexcept(noexcept(_INNER __ref_wrapper_construct_aux< T >(_MSTL declval< U >())))
构造函数
MSTL_NODISCARD MSTL_CONSTEXPR14 T & get() const noexcept
获取包装的引用
MSTL_NODISCARD constexpr T * addressof(T &x) noexcept
获取对象的地址
MSTL_NODISCARD constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
MSTL_CONSTEXPR14 _INNER __invoke_result_aux< Callable, Args... >::type invoke(Callable &&f, Args &&... args) noexcept(is_nothrow_invocable< Callable, Args... >::value)
统一调用接口
#define _MSTL
全局命名空间MSTL前缀
#define MSTL_END_INNER__
结束inner命名空间
#define _INNER
inner命名空间前缀
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
#define MSTL_BEGIN_INNER__
开始inner命名空间
MSTL_NODISCARD constexpr reference_wrapper< T > ref(T &val) noexcept
创建引用包装器
typename unwrap_reference< T >::type unwrap_reference_t
unwrap_reference的便捷别名
MSTL_NODISCARD constexpr reference_wrapper< const T > cref(const T &val) noexcept
创建const引用包装器
typename unwrap_ref_decay< T >::type unwrap_ref_decay_t
unwrap_ref_decay的便捷别名
bool_constant< true > true_type
表示true的类型
typename type_identity< T >::type type_identity_t
type_identity的便捷别名
bool_constant< false > false_type
表示false的类型
typename enable_if< Test, T >::type enable_if_t
enable_if的便捷别名
static constexpr bool value