MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
apply.hpp
浏览该文件的文档.
1#ifndef MSTL_CORE_FUNCTIONAL_APPLY_HPP__
2#define MSTL_CORE_FUNCTIONAL_APPLY_HPP__
3
10
14
17
18template <template <typename...> class, typename, typename>
19struct __apply_unpack_tuple : false_type {};
20
21template <template <typename...> class Trait, typename T, typename... U>
22struct __apply_unpack_tuple<Trait, T, tuple<U...>> : bool_constant<Trait<T, U...>::value> {};
23
24template <template <typename...> class Trait, typename T, typename... U>
25struct __apply_unpack_tuple<Trait, T, tuple<U...>&> : bool_constant<Trait<T, U&...>::value> {};
26
27template <template <typename...> class Trait, typename T, typename... U>
28struct __apply_unpack_tuple<Trait, T, const tuple<U...>> : bool_constant<Trait<T, const U...>::value> {};
29
30template <template <typename...> class Trait, typename T, typename... U>
31struct __apply_unpack_tuple<Trait, T, const tuple<U...>&> : bool_constant<Trait<T, const U&...>::value> {};
32
33
34template <typename F, typename Tuple, size_t... Idx>
35constexpr auto __apply_impl(F&& f, Tuple&& t, _MSTL index_sequence<Idx...>) {
36 return _MSTL invoke(_MSTL forward<F>(f),
39 );
40}
41
44
50
62template <typename Func, typename Tuple>
63constexpr auto apply(Func&& f, Tuple&& t)
64noexcept(_INNER __apply_unpack_tuple<_MSTL is_nothrow_invocable, Func, Tuple>::value) -> decltype(auto) {
66 return _INNER __apply_impl(_MSTL forward<Func>(f), _MSTL forward<Tuple>(t), Indices{});
67}
68 // Tuple
70
72#endif // MSTL_CORE_FUNCTIONAL_APPLY_HPP__
MSTL_NODISCARD constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
MSTL_ALWAYS_INLINE enable_if_t< is_void_v< T >, future_result_t< T > > get(future< T > &f)
通用future结果获取函数
integer_sequence< size_t, Values... > index_sequence
索引序列
make_integer_sequence< size_t, Size > make_index_sequence
生成指定长度的索引序列
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命名空间
constexpr auto apply(Func &&f, Tuple &&t) noexcept(_INNER __apply_unpack_tuple< _MSTL is_nothrow_invocable, Func, Tuple >::value) -> decltype(auto)
将元组元素解包作为参数调用函数
bool_constant< false > false_type
表示false的类型
integral_constant< bool, Value > bool_constant
布尔常量包装器
MSTL统一调用接口
MSTL元组实现