12#ifndef DUMUX_COMMON_TAG_HH
13#define DUMUX_COMMON_TAG_HH
18#include <dune/common/classname.hh>
33template<
class T1,
class T2>
35{
return std::is_same_v<T1, T2>; }
37template<
class T1,
class T2>
39{
return !std::is_same_v<T1, T2>; }
43constexpr auto hasName =
isValid([](
auto&& t) ->
decltype(t.name(),
void()) {});
47template<
class T, std::enable_if_t<std::is_base_of_v<Tag<T>, T>,
int> = 0>
50{ os << t.name();
return os; }
53template<
class T, std::enable_if_t<std::is_base_of_v<Tag<T>, T>,
int> = 0>
57 const auto fullName = Dune::className<T>();
60 const auto pos = fullName.rfind(
"::");
61 const auto name = pos != std::string::npos ? fullName.substr(pos+2) : fullName;
constexpr auto isValid(const Expression &t)
A function that creates a test functor to do class member introspection at compile time.
Definition: isvalid.hh:81
A helper function for class member function introspection.
constexpr auto hasName
Definition: tag.hh:43
constexpr bool operator!=(Tag< T1 >, Tag< T2 >)
Definition: tag.hh:38
auto operator<<(std::ostream &os, const T &t) -> std::enable_if_t< decltype(Detail::hasName(t))::value, std::ostream & >
Return the class name of the tagged type calling t.name()
Definition: tag.hh:48
constexpr bool operator==(Tag< T1 >, Tag< T2 >)
Tags are equality comparable and return true if the tagged types are equal.
Definition: tag.hh:34
Helper class to create (named and comparable) tagged types Tags any given type. The tagged type is eq...
Definition: tag.hh:30