24#ifndef DUMUX_COMMON_TAG_HH
25#define DUMUX_COMMON_TAG_HH
30#include <dune/common/classname.hh>
45template<
class T1,
class T2>
47{
return std::is_same_v<T1, T2>; }
49template<
class T1,
class T2>
51{
return !std::is_same_v<T1, T2>; }
54constexpr auto hasName =
isValid([](
auto&& t) ->
decltype(t.name(),
void()) {});
58template<
class T, std::enable_if_t<std::is_base_of_v<Tag<T>, T>,
int> = 0>
61{ os << t.name();
return os; }
64template<
class T, std::enable_if_t<std::is_base_of_v<Tag<T>, T>,
int> = 0>
68 const auto fullName = Dune::className<T>();
71 const auto pos = fullName.rfind(
"::");
72 const auto name = pos != std::string::npos ? fullName.substr(pos+2) : fullName;
A helper function for class member function introspection.
constexpr auto isValid(const Expression &t)
A function that creates a test functor to do class member introspection at compile time.
Definition: isvalid.hh:93
constexpr bool operator!=(Tag< T1 >, Tag< T2 >)
Definition: tag.hh:50
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:59
constexpr bool operator==(Tag< T1 >, Tag< T2 >)
Tags are equality comparable and return true if the tagged types are equal.
Definition: tag.hh:46
constexpr auto hasName
Definition: tag.hh:54
Helper class to create (named and comparable) tagged types Tags any given type. The tagged type is eq...
Definition: tag.hh:42