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
{
namespace Tools
{
namespace Impl_
{
template <class T>
void ignored_evaluation(std::initializer_list<T>&&) { /* do nothing */ }
}
template <class Functor, class... Args>
constexpr void for_variadic(Functor&& f, Args&&... args)
{
#if AMDIS_HAS_CXX_FOLD_EXPRESSIONS
(f(FWD(args)),...);
#else
Impl_::ignored_evaluation<int>({0, (f(FWD(args)), 0)...});
#endif
}
template <std::size_t... I, class Tuple, class Functor>
constexpr void for_each(std::index_sequence<I...>, Tuple&& tuple, Functor&& f)
{
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)),...);
#else
Impl_::ignored_evaluation<int>({0, (f(get<I>(tuple)), 0)...});
#endif
}
template <class Tuple, class Functor>
......@@ -48,11 +32,7 @@ namespace AMDiS
template <std::size_t I0 = 0, std::size_t... I, class Functor>
constexpr void for_range(std::index_sequence<I...>, Functor&& f)
{
#if AMDIS_HAS_CXX_FOLD_EXPRESSIONS
(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>
......
......@@ -93,31 +93,11 @@ namespace AMDiS
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>
constexpr auto sum(Ts const&... ts)
{
return (ts + ...);
}
#endif
} // end namespace Math
......
......@@ -99,19 +99,11 @@ namespace AMDiS
/// Functor that represents A*B
struct Multiplies
{
#ifdef AMDIS_HAS_CXX_FOLD_EXPRESSIONS
template <class... Ts>
constexpr auto operator()(Ts const&... ts) const
{
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)
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("
#include <iostream>
#include <tuple>
......
......@@ -53,7 +53,6 @@
#cmakedefine AMDIS_HAS_PETSC 1
/* 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_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