Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
5c552e80
Commit
5c552e80
authored
Mar 24, 2021
by
Dennis Gläser
Browse files
Merge branch 'feature/cleanup-property-system' into 'master'
[propertysystem] Some cleanup See merge request
!2512
parents
bed1b628
045ac809
Changes
1
Hide whitespace changes
Inline
Side-by-side
dumux/common/properties/propertysystem.hh
View file @
5c552e80
...
...
@@ -29,19 +29,20 @@
#include <tuple>
#include <type_traits>
namespace
Dumux
{
namespace
Properties
{
namespace
Dumux
::
Properties
{
//! a tag to mark properties as undefined
struct
UndefinedProperty
{};
}
// end namespace Dumux::Properties
//! implementation details for template meta programming
namespace
Detail
{
namespace
Dumux
::
Properties
::
Detail
{
//! check if a property P is defined
template
<
class
P
>
constexpr
auto
isDefinedProperty
(
int
)
->
decltype
(
std
::
integral_constant
<
bool
,
!
std
::
is_same
<
typename
P
::
type
,
UndefinedProperty
>
::
value
>
{})
->
decltype
(
std
::
integral_constant
<
bool
,
!
std
::
is_same
_v
<
typename
P
::
type
,
UndefinedProperty
>>
{})
{
return
{};
}
//! fall back if a Property is defined
...
...
@@ -49,16 +50,15 @@ template<class P>
constexpr
std
::
true_type
isDefinedProperty
(...)
{
return
{};
}
//! check if a TypeTag inherits from other TypeTags
//! the enable_if portion of decltype is only needed for the macro hack to work, if no macros are in use anymore it can be removed,
//! i.e. then trailing return type is then -> decltype(std::declval<typename T::InheritsFrom>(), std::true_type{})
template
<
class
T
>
constexpr
auto
hasParentTypeTag
(
int
)
->
decltype
(
std
::
declval
<
typename
T
::
InheritsFrom
>
(),
std
::
enable_if_t
<!
std
::
is_same
<
typename
T
::
InheritsFrom
,
void
>::
value
,
int
>
{},
std
::
true_type
{})
->
decltype
(
std
::
declval
<
typename
T
::
InheritsFrom
>
(),
std
::
true_type
{})
{
return
{};
}
//! fall back if a TypeTag doesn't inherit
template
<
class
T
>
constexpr
std
::
false_type
hasParentTypeTag
(...)
{
return
{};
}
constexpr
std
::
false_type
hasParentTypeTag
(...)
{
return
{};
}
//! helper alias to concatenate multiple tuples
template
<
class
...
Tuples
>
...
...
@@ -132,10 +132,11 @@ struct GetPropImpl
static_assert
(
!
std
::
is_same
<
type
,
UndefinedProperty
>::
value
,
"Property is undefined!"
);
};
}
// end namespace Detail
}
// end namespace Property
}
// end namespace Dumux::Properties::Detail
namespace
Dumux
{
//! get the type of a property
(equivalent to old macro GET_PROP(...))
//! get the type of a property
template
<
class
TypeTag
,
template
<
class
,
class
>
class
Property
>
using
GetProp
=
typename
Properties
::
Detail
::
GetPropImpl
<
TypeTag
,
Property
>::
type
;
...
...
@@ -144,7 +145,7 @@ using GetProp = typename Properties::Detail::GetPropImpl<TypeTag, Property>::typ
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
//! get the type alias defined in the property
(equivalent to old macro GET_PROP_TYPE(...))
//! get the type alias defined in the property
template
<
class
TypeTag
,
template
<
class
,
class
>
class
Property
>
using
GetPropType
=
typename
Properties
::
Detail
::
GetPropImpl
<
TypeTag
,
Property
>::
type
::
type
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment