CommonLibSSE (powerof3)
FunctionArguments.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "RE/T/TypeTraits.h"
6 
7 namespace RE
8 {
9  namespace BSScript
10  {
11  namespace Impl
12  {
13  template <class... Args, std::size_t... I>
14  void CopyArgsImpl(std::tuple<Args...>& a_tuple, BSScrapArray<Variable>& a_dst, std::index_sequence<I...>)
15  {
16  (a_dst[I].Pack(std::get<I>(a_tuple)), ...);
17  }
18 
19  template <class... Args>
20  void CopyArgs(std::tuple<Args...>& a_tuple, BSScrapArray<Variable>& a_dst)
21  {
22  CopyArgsImpl(a_tuple, a_dst, std::index_sequence_for<Args...>{});
23  }
24  }
25 
26  template <class Enable, class... Args>
28 
29  template <class... Args>
31  std::enable_if_t<
32  std::conjunction_v<
33  is_return_convertible<Args>...>>,
34  Args...> :
35  public IFunctionArguments
36  {
37  private:
38  using super = IFunctionArguments;
39 
40  public:
41  FunctionArguments(Args&&... a_args) :
42  super(),
43  _args(std::forward<Args>(a_args)...)
44  {}
45 
47  super(),
48  _args()
49  {}
50 
52  super(),
53  _args(a_rhs._args)
54  {}
55 
57  super(),
58  _args(std::move(a_rhs._args))
59  {}
60 
61  ~FunctionArguments() override = default; // 00
62 
63  bool operator()(BSScrapArray<Variable>& a_dst) const override // 01
64  {
65  a_dst.resize(sizeof...(Args));
66  auto& args = const_cast<std::add_lvalue_reference_t<std::decay_t<decltype(_args)>>>(_args);
67  Impl::CopyArgs(args, a_dst);
68  return true;
69  }
70 
71  protected:
72  std::tuple<std::decay_t<Args>...> _args;
73  };
74  }
75 
76  template <class... Args>
78 
79  template <class... Args>
81  {
82  return new FunctionArguments<Args...>(std::forward<Args>(a_args)...);
83  }
84 
85  template <>
87  {
89  }
90 }
bool operator()(BSScrapArray< Variable > &a_dst) const override
Definition: FunctionArguments.h:63
Definition: FunctionArguments.h:27
Definition: IFunctionArguments.h:12
Definition: ZeroFunctionArguments.h:10
Definition: BSTArray.h:378
void CopyArgsImpl(std::tuple< Args... > &a_tuple, BSScrapArray< Variable > &a_dst, std::index_sequence< I... >)
Definition: FunctionArguments.h:14
void CopyArgs(std::tuple< Args... > &a_tuple, BSScrapArray< Variable > &a_dst)
Definition: FunctionArguments.h:20
Definition: AbsorbEffect.h:6
BSScript::IFunctionArguments * MakeFunctionArguments(Args &&... a_args)
Definition: FunctionArguments.h:80
Definition: EffectArchetypes.h:65