strongdef: add default constructor if the type supports it
This commit is contained in:
parent
6dea530f6e
commit
6f3952abcb
@ -29,7 +29,11 @@ namespace util {
|
|||||||
using value_type = T;
|
using value_type = T;
|
||||||
using tag_type = Tag;
|
using tag_type = Tag;
|
||||||
|
|
||||||
constexpr strongdef () = delete;
|
// TODO: ideally we'd default the constructor, but templated
|
||||||
|
// constructors can't be defaulted? So we just stub one out.
|
||||||
|
template <typename = std::enable_if_t<std::is_default_constructible_v<T>>>
|
||||||
|
constexpr strongdef () { ; }
|
||||||
|
|
||||||
constexpr strongdef (const T &_data): data (_data) { ; }
|
constexpr strongdef (const T &_data): data (_data) { ; }
|
||||||
|
|
||||||
// explicitly disable assignment with unequal types or tags. this
|
// explicitly disable assignment with unequal types or tags. this
|
||||||
@ -59,6 +63,9 @@ namespace util {
|
|||||||
operator const T& (void) const& { return data; }
|
operator const T& (void) const& { return data; }
|
||||||
operator T& (void) & { return data; }
|
operator T& (void) & { return data; }
|
||||||
|
|
||||||
|
auto const& value (void) const { return data; }
|
||||||
|
auto & value (void) { return data; }
|
||||||
|
|
||||||
// explicitly disable equality with unequal types or tags. this
|
// explicitly disable equality with unequal types or tags. this
|
||||||
// prevents the conversion operator getting invoked and falsely
|
// prevents the conversion operator getting invoked and falsely
|
||||||
// allowing equality with different types or tags.
|
// allowing equality with different types or tags.
|
||||||
|
Loading…
Reference in New Issue
Block a user