8 #ifndef SRC_TOOLS_MIXED_HH_
9 #define SRC_TOOLS_MIXED_HH_
14 #include <type_traits>
34 template <
char... Digits>
38 char digits[] = {Digits...};
41 return digits[0] -
'0';
44 template <
char... Digits>
56 template<
template<
IntDim ...>
class T>
59 template<
template<
IntDim ...>
class T>
63 template<
template<
IntDim ...>
class T,
int lower_dim=0>
88 template <
template<
IntDim...>
class TT>
94 T<3>( (other[3_d]) ) )
95 { static_assert(std::is_convertible<TT<0>, T<0>>::
value,
"Non-convertible types!"); }
97 Mixed(
const T<0> &p0,
const T<1> &p1,
const T<2> &p2,
const T<3> &p3)
101 Mixed(T<0> &&p0, T<1> &&p1, T<2> &&p2, T<3> &&p3)
106 template<
typename... Args>
109 T<0>(
std::forward<Args>(args)...),
110 T<1>(
std::forward<Args>(args)...),
111 T<2>(
std::forward<Args>(args)...),
112 T<3>(
std::forward<Args>(args)...))
119 template <IntDim i_dim>
122 return std::get<i_dim>(*
this);
125 template <IntDim i_dim>
128 return std::get<i_dim>(*
this);
134 template<
template<
IntDim...>
class TParent,
typename std::enable_if<std::is_convertible<TParent<0>, T<0>>
::value, T<0> >::type >
138 TParent<0>(this->
operator[](0_d)),
139 TParent<1>(this->
operator[](1_d)),
140 TParent<2>(this->
operator[](2_d)),
141 TParent<3>(this->
operator[](3_d)));
150 template<
template<
IntDim ...>
class T>
158 template <
template<
IntDim...>
class TT>
164 { static_assert(std::is_convertible<TT<1>, T<1>>::
value,
"Non-convertible types!"); }
166 Mixed(
const T<1> &p1,
const T<2> &p2,
const T<3> &p3)
170 Mixed( T<1> &&p1, T<2> &&p2, T<3> &&p3)
175 template<
typename... Args>
178 T<1>(
std::forward<Args>(args)...),
179 T<2>(
std::forward<Args>(args)...),
180 T<3>(
std::forward<Args>(args)...))
188 template <IntDim i_dim>
194 template <IntDim i_dim>
200 template<
template<
IntDim...>
class TParent,
typename std::enable_if<std::is_convertible<TParent<1>, T<1>>
::value, T<1> >::type >
204 TParent<1>(this->
operator[](1_d)),
205 TParent<2>(this->
operator[](2_d)),
206 TParent<3>(this->
operator[](3_d)));
236 template<
template<
IntDim...>
class T>
238 std::shared_ptr<T<0>>, std::shared_ptr<T<1>>,
239 std::shared_ptr<T<2>>, std::shared_ptr<T<3>>>;
241 template<
template<
IntDim...>
class T>
243 std::shared_ptr<T<2>>, std::shared_ptr<T<3>>>;
246 template<
template<
IntDim...>
class T,
int lower_dim=0>
263 template <IntDim dim>
264 using TPtr = std::shared_ptr<T<dim>>;
266 template <
template<
IntDim...>
class TT>
279 template<
typename... Args>
282 std::make_shared<T<0>>(
std::forward<Args>(args)...),
283 std::make_shared<T<1>>(
std::forward<Args>(args)...),
284 std::make_shared<T<2>>(
std::forward<Args>(args)...),
285 std::make_shared<T<3>>(
std::forward<Args>(args)...))
294 template <IntDim i_dim>
297 return std::get<i_dim>(*
this);
300 template <IntDim i_dim>
303 return std::get<i_dim>(*
this);
308 *(this->
operator[](0_d)),
309 *(this->
operator[](1_d)),
310 *(this->
operator[](2_d)),
311 *(this->
operator[](3_d)));
319 template<
template<
IntDim...>
class T>
326 template <IntDim dim>
327 using TPtr = std::shared_ptr<T<dim>>;
329 template <
template<
IntDim...>
class TT>
341 template<
typename... Args>
344 std::make_shared<T<1>>(
std::forward<Args>(args)...),
345 std::make_shared<T<2>>(
std::forward<Args>(args)...),
346 std::make_shared<T<3>>(
std::forward<Args>(args)...))
355 template <IntDim i_dim>
361 template <IntDim i_dim>
370 *(this->
operator[](1_d)),
371 *(this->
operator[](2_d)),
372 *(this->
operator[](3_d)));
std::shared_ptr< T< i_dim > > operator[](Dim< i_dim >)
const std::shared_ptr< T< i_dim > > operator[](Dim< i_dim >) const
MixedPtr(TPtr< 1 > p1, TPtr< 2 > p2, TPtr< 3 > p3)
MixedPtr(const MixedPtr< TT, 1 > &other)
std::shared_ptr< T< dim > > TPtr
const std::shared_ptr< T< i_dim > > operator[](Dim< i_dim >) const
std::shared_ptr< T< dim > > TPtr
MixedPtr(TPtr< 0 > p0, TPtr< 1 > p1, TPtr< 2 > p2, TPtr< 3 > p3)
std::shared_ptr< T< i_dim > > operator[](Dim< i_dim >)
MixedPtr(const MixedPtr< TT > &other)
T< i_dim > & operator[](Dim< i_dim >)
const T< i_dim > & operator[](Dim< i_dim >) const
Mixed(const T< 1 > &p1, const T< 2 > &p2, const T< 3 > &p3)
Mixed(T< 1 > &&p1, T< 2 > &&p2, T< 3 > &&p3)
Mixed(const Mixed< TT, 1 > &other)
const T< i_dim > & operator[](Dim< i_dim >) const
Mixed(T< 0 > &&p0, T< 1 > &&p1, T< 2 > &&p2, T< 3 > &&p3)
T< i_dim > & operator[](Dim< i_dim >)
Mixed(const Mixed< TT > &other)
Mixed(const T< 0 > &p0, const T< 1 > &p1, const T< 2 > &p2, const T< 3 > &p3)
static constexpr bool value
std::tuple< T< 1 >, T< 2 >, T< 3 > > _MixedBase1
std::tuple< std::shared_ptr< T< 0 > >, std::shared_ptr< T< 1 > >, std::shared_ptr< T< 2 > >, std::shared_ptr< T< 3 > >> _MixedPtrBase0
**
constexpr std::size_t parse_dim()
std::tuple< T< 0 >, T< 1 >, T< 2 >, T< 3 > > _MixedBase0
unsigned int IntDim
A dimension index type.
std::tuple< std::shared_ptr< T< 1 > >, std::shared_ptr< T< 2 > >, std::shared_ptr< T< 3 > >> _MixedPtrBase1