Commit 1945525c authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

remove check for fold expressions

parent bf6a91cb
...@@ -9,33 +9,17 @@ namespace AMDiS ...@@ -9,33 +9,17 @@ namespace AMDiS
{ {
namespace Tools namespace Tools
{ {
namespace Impl_
{
template <class T>
void ignored_evaluation(std::initializer_list<T>&&) { /* do nothing */ }
}
template <class Functor, class... Args> template <class Functor, class... Args>
constexpr void for_variadic(Functor&& f, Args&&... args) constexpr void for_variadic(Functor&& f, Args&&... args)
{ {
#if AMDIS_HAS_CXX_FOLD_EXPRESSIONS
(f(FWD(args)),...); (f(FWD(args)),...);
#else
Impl_::ignored_evaluation<int>({0, (f(FWD(args)), 0)...});
#endif
} }
template <std::size_t... I, class Tuple, class Functor> template <std::size_t... I, class Tuple, class Functor>
constexpr void for_each(std::index_sequence<I...>, Tuple&& tuple, Functor&& f) constexpr void for_each(std::index_sequence<I...>, Tuple&& tuple, Functor&& f)
{ {
using std::get; using std::get;
#if AMDIS_HAS_EXPANSION_STATEMENTS
for... (auto&& t : tuple) { f(FWD(t)); }
#elif AMDIS_HAS_CXX_FOLD_EXPRESSIONS
(f(get<I>(tuple)),...); (f(get<I>(tuple)),...);
#else
Impl_::ignored_evaluation<int>({0, (f(get<I>(tuple)), 0)...});
#endif
} }
template <class Tuple, class Functor> template <class Tuple, class Functor>
...@@ -48,11 +32,7 @@ namespace AMDiS ...@@ -48,11 +32,7 @@ namespace AMDiS
template <std::size_t I0 = 0, std::size_t... I, class Functor> template <std::size_t I0 = 0, std::size_t... I, class Functor>
constexpr void for_range(std::index_sequence<I...>, Functor&& f) constexpr void for_range(std::index_sequence<I...>, Functor&& f)
{ {
#if AMDIS_HAS_CXX_FOLD_EXPRESSIONS
(f(index_t<I0+I>{}),...); (f(index_t<I0+I>{}),...);
#else
Impl_::ignored_evaluation<int>({0, (f(index_t<I0+I>{}), 0)...});
#endif
} }
template <std::size_t I0, std::size_t I1, class Functor> template <std::size_t I0, std::size_t I1, class Functor>
......
...@@ -93,31 +93,11 @@ namespace AMDiS ...@@ -93,31 +93,11 @@ namespace AMDiS
return 0.0; return 0.0;
} }
#ifndef AMDIS_HAS_CXX_FOLD_EXPRESSIONS
template <class T>
constexpr auto const& sum(T const& t)
{
return t;
}
template <class T0, class T1>
constexpr auto sum(T0 const& t0, T1 const& t1)
{
return t0 + t1;
}
template <class T0, class... Ts>
constexpr auto sum(T0 const& t0, Ts const&... ts)
{
return t0 + sum(ts...);
}
#else
template <class... Ts> template <class... Ts>
constexpr auto sum(Ts const&... ts) constexpr auto sum(Ts const&... ts)
{ {
return (ts + ...); return (ts + ...);
} }
#endif
} // end namespace Math } // end namespace Math
......
...@@ -99,19 +99,11 @@ namespace AMDiS ...@@ -99,19 +99,11 @@ namespace AMDiS
/// Functor that represents A*B /// Functor that represents A*B
struct Multiplies struct Multiplies
{ {
#ifdef AMDIS_HAS_CXX_FOLD_EXPRESSIONS
template <class... Ts> template <class... Ts>
constexpr auto operator()(Ts const&... ts) const constexpr auto operator()(Ts const&... ts) const
{ {
return (ts * ...); return (ts * ...);
} }
#else
template <class T, class S>
constexpr auto operator()(T const& lhs, S const& rhs) const
{
return lhs * rhs;
}
#endif
}; };
......
...@@ -2,20 +2,6 @@ include(CheckCXXSourceCompiles) ...@@ -2,20 +2,6 @@ include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS "-pedantic-errors") set(CMAKE_REQUIRED_FLAGS "-pedantic-errors")
# fold expressions (a + ...)
check_cxx_source_compiles("
template <class... Args>
int f(Args... args)
{
return (args + ...);
}
int main()
{
f(0,1,2,3,4,5);
}
" AMDIS_HAS_CXX_FOLD_EXPRESSIONS
)
check_cxx_source_compiles(" check_cxx_source_compiles("
#include <iostream> #include <iostream>
#include <tuple> #include <tuple>
......
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
#cmakedefine AMDIS_HAS_PETSC 1 #cmakedefine AMDIS_HAS_PETSC 1
/* some detected compiler features may be used in AMDiS */ /* some detected compiler features may be used in AMDiS */
#cmakedefine AMDIS_HAS_CXX_FOLD_EXPRESSIONS 1
#cmakedefine AMDIS_HAS_EXPANSION_STATEMENTS 1 #cmakedefine AMDIS_HAS_EXPANSION_STATEMENTS 1
#cmakedefine AMDIS_HAS_CXX_AUTO_TEMPLATE_PARAMETER 1 #cmakedefine AMDIS_HAS_CXX_AUTO_TEMPLATE_PARAMETER 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment