entity
Entity/Component System for C++
invoke.hpp
Go to the documentation of this file.
1 // ****************************************************************************
2 // entity/algorithm/simd/detail/invoke.hpp
3 //
4 // Invoker helper function for simd to workaround limitations
5 // of boost::fusion::invoke
6 //
7 // Copyright Chris Glover 2014-2015
8 //
9 // Distributed under the Boost Software License, Version 1.0.
10 // See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt
12 //
13 // ****************************************************************************
14 #ifndef _ENTITY_ALGORITHM_SIMD_DETAIL_INVOKE_H_INCLUDED_
15 #define _ENTITY_ALGORITHM_SIMD_DETAIL_INVOKE_H_INCLUDED_
16 
17 #include <boost/fusion/sequence/intrinsic/at.hpp>
18 
19 #include "entity/config.hpp" // IWYU pragma: keep
20 
21 // ----------------------------------------------------------------------------
22 //
23 namespace entity { namespace simd { namespace detail
24 {
25  template<typename Source, typename Target>
26  struct make_type
27  {
28  typedef Target type;
29  };
30 
31  template<typename Fn, template<typename> class Sequence, typename intrinsic_type>
32  void invoke(Fn f, Sequence<intrinsic_type&>& values)
33  {
34  using boost::fusion::at_c;
35  f(at_c<0>(values));
36  }
37 
38  template<typename Fn, template<typename, typename> class Sequence, typename intrinsic_type>
39  void invoke(Fn f, Sequence<intrinsic_type&, intrinsic_type&>& values)
40  {
41  using boost::fusion::at_c;
42  f(at_c<0>(values), at_c<1>(values));
43  }
44 
45  template<typename Fn, template<typename, typename, typename> class Sequence, typename intrinsic_type>
46  void invoke(Fn f, Sequence<intrinsic_type&, intrinsic_type&, intrinsic_type&>& values)
47  {
48  using boost::fusion::at_c;
49  f(at_c<0>(values), at_c<1>(values), at_c<2>(values));
50  }
51 
52  template<typename Fn, template<typename, typename, typename, typename> class Sequence, typename intrinsic_type>
53  void invoke(Fn f, Sequence<intrinsic_type&, intrinsic_type&, intrinsic_type&, intrinsic_type&>& values)
54  {
55  using boost::fusion::at_c;
56  f(at_c<0>(values), at_c<1>(values), at_c<2>(values), at_c<3>(values));
57  }
58 }}}
59 
60 #endif // _ENTITY_ALGORITHM_SIMD_DETAIL_INVOKE_H_INCLUDED_
void invoke(Fn f, Sequence< intrinsic_type & > &values)
Definition: invoke.hpp:32