Skip to content

Commit

Permalink
remove GT_BROKEN_TEMPLATE_ALIASES
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Mosimann committed May 21, 2019
1 parent ad1af7b commit d549ba7
Show file tree
Hide file tree
Showing 27 changed files with 21 additions and 152 deletions.
28 changes: 6 additions & 22 deletions include/gridtools/common/tuple_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,12 @@ namespace gridtools {
template <class T>
decltype(tuple_from_types(std::declval<T>())) get_from_types(T);

#if GT_BROKEN_TEMPLATE_ALIASES
#define GT_TUPLE_UTIL_DEFINE_SAFE_ALIAS(name) \
template <class, class = void> \
struct name; \
template <class T> \
struct name<T, void_t<decltype(::gridtools::tuple_util::traits::get_##name(std::declval<T>()))>> { \
using type = decltype(::gridtools::tuple_util::traits::get_##name(std::declval<T>())); \
}
#else
#define GT_TUPLE_UTIL_DEFINE_SAFE_ALIAS(name) \
template <class T> \
using name = decltype(::gridtools::tuple_util::traits::get_##name(std::declval<T>()))
#endif
GT_TUPLE_UTIL_DEFINE_SAFE_ALIAS(getter);
GT_TUPLE_UTIL_DEFINE_SAFE_ALIAS(to_types);
GT_TUPLE_UTIL_DEFINE_SAFE_ALIAS(from_types);
#undef GT_TUPLE_UTIL_DEFINE_SAFE_ALIAS
template <class T>
using getter = decltype(::gridtools::tuple_util::traits::get_getter(std::declval<T>()));
template <class T>
using to_types = decltype(::gridtools::tuple_util::traits::get_to_types(std::declval<T>()));
template <class T>
using from_types = decltype(::gridtools::tuple_util::traits::get_from_types(std::declval<T>()));
} // namespace traits
/// @endcond

Expand Down Expand Up @@ -569,13 +558,8 @@ namespace gridtools {

template <class Fun>
struct fold_f {
#if GT_BROKEN_TEMPLATE_ALIASES
template <class S, class T>
struct meta_fun : get_fun_result<Fun>::template apply<S, T> {};
#else
template <class S, class T>
using meta_fun = typename get_fun_result<Fun>::template apply<S, T>;
#endif
Fun m_fun;

template <size_t I, size_t N, class State, class Tup, enable_if_t<I == N, int> = 0>
Expand Down
1 change: 0 additions & 1 deletion include/gridtools/meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
#include "meta/debug.hpp"
#include "meta/dedup.hpp"
#include "meta/defer.hpp"
#include "meta/defs.hpp"
#include "meta/drop_back.hpp"
#include "meta/drop_front.hpp"
#include "meta/filter.hpp"
Expand Down
5 changes: 1 addition & 4 deletions include/gridtools/meta/always.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#pragma once

#include "defs.hpp"
#include "id.hpp"
#include "macros.hpp"

Expand All @@ -22,13 +21,11 @@ namespace gridtools {
template <class...>
struct apply : id<T> {};
};
}
#if !GT_BROKEN_TEMPLATE_ALIASES
} // namespace lazy
template <class T>
struct always {
template <class...>
using apply = T;
};
#endif
} // namespace meta
} // namespace gridtools
5 changes: 1 addition & 4 deletions include/gridtools/meta/at.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <cstddef>
#include <type_traits>

#include "defs.hpp"
#include "first.hpp"
#include "macros.hpp"
#include "make_indices.hpp"
Expand Down Expand Up @@ -42,13 +41,11 @@ namespace gridtools {

template <class List, class N>
using at = at_c<List, N::value>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
} // namespace lazy
// 'direct' versions of lazy functions
template <class List, class N>
using at = typename lazy::at_c<List, N::value>::type;
template <class List, std::size_t N>
using at_c = typename lazy::at_c<List, N>::type;
#endif
} // namespace meta
} // namespace gridtools
5 changes: 2 additions & 3 deletions include/gridtools/meta/combine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <cstddef>

#include "curry_fun.hpp"
#include "defs.hpp"
#include "drop_front.hpp"
#include "length.hpp"
#include "macros.hpp"
Expand Down Expand Up @@ -74,6 +73,6 @@ namespace gridtools {
};
template <template <class...> class F, class List>
struct combine<F, List> : combine_impl<F, List, length<List>::value> {};
}
} // namespace meta
} // namespace lazy
} // namespace meta
} // namespace gridtools
4 changes: 1 addition & 3 deletions include/gridtools/meta/ctor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ namespace gridtools {
struct ctor;
template <template <class...> class L, class... Ts>
struct ctor<L<Ts...>> : defer<L> {};
}
#if !GT_BROKEN_TEMPLATE_ALIASES
} // namespace lazy
template <class>
struct ctor;
template <template <class...> class L, class... Ts>
struct ctor<L<Ts...>> : curry<L> {};
#endif
} // namespace meta
} // namespace gridtools
3 changes: 0 additions & 3 deletions include/gridtools/meta/dedup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#pragma once

#include "clear.hpp"
#include "defs.hpp"
#include "fold.hpp"
#include "if.hpp"
#include "macros.hpp"
Expand All @@ -31,9 +30,7 @@ namespace gridtools {
template <class List>
using dedup = lfold<dedup_step_impl, typename clear<List>::type, List>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
template <class List>
using dedup = typename lazy::lfold<dedup_step_impl, typename lazy::clear<List>::type, List>::type;
#endif
} // namespace meta
} // namespace gridtools
28 changes: 0 additions & 28 deletions include/gridtools/meta/defs.hpp

This file was deleted.

5 changes: 1 addition & 4 deletions include/gridtools/meta/drop_back.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <cstddef>

#include "defs.hpp"
#include "drop_front.hpp"
#include "macros.hpp"
#include "reverse.hpp"
Expand All @@ -25,15 +24,13 @@ namespace gridtools {

template <class N, class List>
using drop_back = reverse<typename drop_front_c<N::value, typename reverse<List>::type>::type>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
} // namespace lazy
template <std::size_t N, class List>
using drop_back_c =
typename lazy::reverse<typename lazy::drop_front_c<N, typename lazy::reverse<List>::type>::type>::type;

template <class N, class List>
using drop_back = typename lazy::reverse<
typename lazy::drop_front_c<N::value, typename lazy::reverse<List>::type>::type>::type;
#endif
} // namespace meta
} // namespace gridtools
5 changes: 1 addition & 4 deletions include/gridtools/meta/drop_front.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <cstddef>

#include "defs.hpp"
#include "id.hpp"
#include "list.hpp"
#include "macros.hpp"
Expand Down Expand Up @@ -41,12 +40,10 @@ namespace gridtools {

template <std::size_t N, class List>
using drop_front_c = drop_front_impl<typename repeat_c<N, void>::type, List>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
} // namespace lazy
template <std::size_t N, class List>
using drop_front_c = typename lazy::drop_front_impl<typename repeat_c<N, void>::type, List>::type;
template <class N, class List>
using drop_front = typename lazy::drop_front_impl<typename repeat_c<N::value, void>::type, List>::type;
#endif
} // namespace meta
} // namespace gridtools
3 changes: 0 additions & 3 deletions include/gridtools/meta/flatten.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include "combine.hpp"
#include "concat.hpp"
#include "defs.hpp"
#include "macros.hpp"

namespace gridtools {
Expand All @@ -26,9 +25,7 @@ namespace gridtools {
template <class Lists>
using flatten = combine<meta::concat, Lists>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
template <class Lists>
using flatten = typename lazy::combine<concat, Lists>::type;
#endif
} // namespace meta
} // namespace gridtools
5 changes: 1 addition & 4 deletions include/gridtools/meta/id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#pragma once

#include "defs.hpp"
#include "macros.hpp"

namespace gridtools {
Expand All @@ -23,10 +22,8 @@ namespace gridtools {
struct id {
using type = T;
};
}
#if !GT_BROKEN_TEMPLATE_ALIASES
} // namespace lazy
template <class T>
using id = T;
#endif
} // namespace meta
} // namespace gridtools
4 changes: 1 addition & 3 deletions include/gridtools/meta/if.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ namespace gridtools {

template <bool Cond, class Lhs, class Rhs>
using if_c = std::conditional<Cond, Lhs, Rhs>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
} // namespace lazy
template <class Cond, class Lhs, class Rhs>
using if_ = typename std::conditional<Cond::value, Lhs, Rhs>::type;

template <bool Cond, class Lhs, class Rhs>
using if_c = typename std::conditional<Cond, Lhs, Rhs>::type;
#endif
} // namespace meta
} // namespace gridtools
3 changes: 0 additions & 3 deletions include/gridtools/meta/last.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#pragma once

#include "at.hpp"
#include "defs.hpp"
#include "length.hpp"
#include "macros.hpp"

Expand All @@ -21,9 +20,7 @@ namespace gridtools {
template <class List>
using last = at_c<List, length<List>::value - 1>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
template <class List>
using last = typename lazy::at_c<List, length<List>::value - 1>::type;
#endif
} // namespace meta
} // namespace gridtools
10 changes: 0 additions & 10 deletions include/gridtools/meta/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,13 @@

#include <boost/preprocessor.hpp>

#include "defs.hpp"

// internal
#define GT_META_INTERNAL_APPLY(fun, args) BOOST_PP_REMOVE_PARENS(fun)<BOOST_PP_REMOVE_PARENS(args)>

#if GT_BROKEN_TEMPLATE_ALIASES

#error unsupported

#else

#define GT_META_DELEGATE_TO_LAZY(fun, signature, args) \
template <BOOST_PP_REMOVE_PARENS(signature)> \
using fun = typename lazy::fun<BOOST_PP_REMOVE_PARENS(args)>::type

#endif

/**
* NVCC bug workaround: sizeof... works incorrectly within template alias context.
*/
Expand Down
5 changes: 1 addition & 4 deletions include/gridtools/meta/make_indices.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <cstddef>

#include "defs.hpp"
#include "iseq_to_list.hpp"
#include "length.hpp"
#include "list.hpp"
Expand All @@ -36,14 +35,12 @@ namespace gridtools {
*/
template <class List, template <class...> class L = list>
using make_indices_for = iseq_to_list<make_index_sequence<length<List>::value>, L>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
} // namespace lazy
template <std::size_t N, template <class...> class L = list>
using make_indices_c = typename lazy::iseq_to_list<make_index_sequence<N>, L>::type;
template <class N, template <class...> class L = list>
using make_indices = typename lazy::iseq_to_list<make_index_sequence<N::value>, L>::type;
template <class List, template <class...> class L = list>
using make_indices_for = typename lazy::iseq_to_list<make_index_sequence<length<List>::value>, L>::type;
#endif
} // namespace meta
} // namespace gridtools
3 changes: 0 additions & 3 deletions include/gridtools/meta/pop_back.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#pragma once

#include "defs.hpp"
#include "macros.hpp"
#include "pop_front.hpp"
#include "reverse.hpp"
Expand All @@ -21,10 +20,8 @@ namespace gridtools {
template <class List>
using pop_back = reverse<typename pop_front<typename reverse<List>::type>::type>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
template <class List>
using pop_back =
typename lazy::reverse<typename lazy::pop_front<typename lazy::reverse<List>::type>::type>::type;
#endif
} // namespace meta
} // namespace gridtools
5 changes: 1 addition & 4 deletions include/gridtools/meta/repeat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <cstddef>

#include "defs.hpp"
#include "list.hpp"
#include "macros.hpp"

Expand Down Expand Up @@ -51,12 +50,10 @@ namespace gridtools {

template <class N, class T>
using repeat = repeat_c<N::value, T>;
}
#if !GT_BROKEN_TEMPLATE_ALIASES
} // namespace lazy
template <std::size_t N, class T>
using repeat_c = typename lazy::repeat_c<N, T>::type;
template <class N, class T>
using repeat = typename lazy::repeat_c<N::value, T>::type;
#endif
} // namespace meta
} // namespace gridtools
Loading

0 comments on commit d549ba7

Please sign in to comment.