entity
Entity/Component System for C++
tie.hpp
Go to the documentation of this file.
1 // ****************************************************************************
2 // entity/component/tie.hpp
3 //
4 // Ties component pools together to be used with algorithms
5 // iterators etc.
6 // Replaces the need to use variadics everywhere and
7 // possibly makes client code more readable by explicitly
8 // tieing component pools together.
9 //
10 // Copyright Chris Glover 2014-2015
11 //
12 // Distributed under the Boost Software License, Version 1.0.
13 // See accompanying file LICENSE_1_0.txt or copy at
14 // http://www.boost.org/LICENSE_1_0.txt
15 //
16 // ****************************************************************************
17 #pragma once
18 #include <boost/fusion/container/vector.hpp>
19 
20 // ----------------------------------------------------------------------------
21 //
22 namespace entity { namespace component
23 {
24  // ------------------------------------------------------------------------
25  //
26 #if ENTITY_SUPPORT_VARIADICS
27  template<typename... Pools>
28  boost::fusion::vector<Pools&...> tie(Pools&... pools)
29  {
30  return boost::fusion::vector<Pools&...>(pools...);
31  }
32 #else
33  template<typename Pool>
34  boost::fusion::vector<Pool&> tie(Pool& pool)
35  {
36  return boost::fusion::vector<Pool&>(pool);
37  }
38 
39  template<typename Pool1, typename Pool2>
40  boost::fusion::vector<Pool1&, Pool2&> tie(Pool1& pool_1, Pool2& pool_2)
41  {
42  return boost::fusion::vector<Pool1&, Pool2&>(pool_1, pool_2);
43  }
44 
45  template<typename Pool1, typename Pool2, typename Pool3>
46  boost::fusion::vector<Pool1&, Pool2&, Pool3&> tie(Pool1& pool_1, Pool2& pool_2, Pool3& pool_3)
47  {
48  return boost::fusion::vector<Pool1&, Pool2&, Pool3&>(pool_1, pool_2, pool_3);
49  }
50 #endif
51 } } // namespace entity { namespace component {
boost::fusion::vector< Pools &...> tie(Pools &...pools)
Definition: tie.hpp:28