5 #ifndef __NODAMUSHI_SVD_NORMALIZE_NULLABLE_HPP__ 6 #define __NODAMUSHI_SVD_NORMALIZE_NULLABLE_HPP__ 9 # include <type_traits> 23 static_assert(std::is_fundamental<T>::value
24 || std::is_enum<T>::value
25 ,
"T must be fundamental or enum");
31 template<
bool attribute,
bool required,
char... name>
32 nullable(const ::nodamushi::svd::value<T,attribute,required,name...> & v):
33 t(v.
get(static_cast<T>(0))),enable(v){}
41 operator bool()const noexcept{
return enable;}
42 bool empty()const noexcept{
return !enable;}
62 return enable && t ==v;
67 return !enable || t != v;
70 T
get(T defaultValue)
const noexcept{
return enable?t:defaultValue;}
73 T
get()
const{
return enable? t: FUNC();}
75 template<
typename SRC,T FUNC(const SRC&)>
76 T
get(
const SRC* src)
const{
return enable? t: FUNC(*src);}
86 #endif // __NODAMUSHI_SVD_NORMALIZE_NULLABLE_HPP__
nullable(const ::nodamushi::svd::value< T, attribute, required, name... > &v)
bool empty() const noexcept
bool operator!=(T v) const noexcept
a data container like optional type.
T get(T defaultValue) const noexcept
bool operator==(T v) const noexcept
nullable & clear()
clear value
T get(const SRC *src) const
value class, empty_value_access_error class
nullable & operator=(const nullable &)=default