Skip to content
Snippets Groups Projects
Commit 0d63a6a7 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

added tests for is_template

parent 4458a050
No related branches found
No related tags found
1 merge request!54add traits for testing whether something is a template or a type and add enable_if_all
......@@ -103,13 +103,22 @@ namespace AMDiS
constexpr bool is_template() { return true; }
#if AMDIS_HAS_CXX_AUTO_TEMPLATE_PARAMETER
template <template <class,auto...> class>
template <template <auto...> class>
constexpr bool is_template() { return true; }
template <template <class,auto,auto...> class>
constexpr bool is_template() { return true; }
#else
template <template <class,int...> class>
template <template <int...> class>
constexpr bool is_template() { return true; }
template <template <class,int,int...> class>
constexpr bool is_template() { return true; }
template <template <std::size_t...> class>
constexpr bool is_template() { return true; }
template <template <class,std::size_t...> class>
template <template <class,std::size_t,std::size_t...> class>
constexpr bool is_template() { return true; }
#endif
......
......@@ -72,3 +72,6 @@ dune_add_test(SOURCES TreeDataTest.cpp
dune_add_test(SOURCES TreeContainerTest.cpp
LINK_LIBRARIES amdis)
dune_add_test(SOURCES TypeTraitsTest.cpp
LINK_LIBRARIES amdis)
#include <amdis/AMDiS.hpp>
#include <amdis/common/TypeTraits.hpp>
using namespace AMDiS;
template <std::size_t i>
struct A {};
template <class T>
struct B {};
template <class T, std::size_t i>
struct C {};
struct D {};
int main(int argc, char** argv)
{
Environment env(argc, argv);
static_assert(is_template<A>(), "");
static_assert(is_template<B>(), "");
static_assert(is_template<C>(), "");
static_assert(not is_template<std::size_t>(), "");
static_assert(not is_template<D>(), "");
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment