VCCC  2024.05
VisualCamp Common C++ library
apply.hpp
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2020/12/08.
3 # */
4 #
5 # ifndef VCCC_MATH_CALCULUS_DETAIL_APPLY_HPP
6 # define VCCC_MATH_CALCULUS_DETAIL_APPLY_HPP
7 #
8 # include <cstdlib>
9 # include <utility>
10 # include <tuple>
11 # include <type_traits>
12 
13 namespace vccc {
14 namespace internal {
15 namespace math {
16 
17 template<typename Func, typename Tuple, std::size_t ...I, typename ...Args>
18 constexpr inline decltype(auto)
19 applyTupleAndVariadicsImpl(Func&& f, Tuple&& tuple, std::index_sequence<I...>, Args&&... args) {
20  return std::forward<Func>(f)(std::get<I>(std::forward<Tuple>(tuple))..., std::forward<Args>(args)...);
21 }
22 
23 template<typename Func, typename Tuple, typename ...Args>
24 constexpr inline decltype(auto)
25 applyTupleAndVariadics(Func&& f, Tuple&& tup, Args&&... args) {
26  return applyTupleAndVariadicsImpl(std::forward<Func>(f),
27  std::forward<Tuple>(tup),
28  std::make_index_sequence<std::tuple_size<std::decay_t<Tuple>>::value>{},
29  std::forward<Args>(args)...);
30 }
31 
32 } // namespace math
33 } // namespace internal
34 } // namespace vccc
35 
36 # endif // VCCC_MATH_CALCULUS_DETAIL_APPLY_HPP
Definition: matrix.hpp:495
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35