mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add sprout::optional
This commit is contained in:
parent
9b9956f810
commit
8cb432dee1
15 changed files with 574 additions and 81 deletions
61
sprout/optional/get.hpp
Normal file
61
sprout/optional/get.hpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
#ifndef SPROUT_OPTIONAL_GET_HPP
|
||||
#define SPROUT_OPTIONAL_GET_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/optional/optional.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// get
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename sprout::optional<T>::reference_const_type
|
||||
get(sprout::optional<T> const& x) {
|
||||
return x.get();
|
||||
}
|
||||
template<typename T>
|
||||
inline typename sprout::optional<T>::reference_type
|
||||
get(sprout::optional<T>& x) {
|
||||
return x.get();
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename sprout::optional<T>::pointer_const_type
|
||||
get(sprout::optional<T> const* x) {
|
||||
return x->get_ptr();
|
||||
}
|
||||
template<typename T>
|
||||
inline typename sprout::optional<T>::pointer_type
|
||||
get(sprout::optional<T>* x) {
|
||||
return x->get_ptr();
|
||||
}
|
||||
|
||||
//
|
||||
// get_pointer
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename sprout::optional<T>::pointer_const_type
|
||||
get_pointer(sprout::optional<T> const& x) {
|
||||
return x.get_pointer();
|
||||
}
|
||||
template<typename T>
|
||||
inline typename sprout::optional<T>::pointer_type
|
||||
get_pointer(sprout::optional<T>& x) {
|
||||
return x.get_pointer();
|
||||
}
|
||||
|
||||
//
|
||||
// get_optional_value_or
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename sprout::optional<T>::reference_const_type
|
||||
get_optional_value_or(sprout::optional<T> const& x, typename sprout::optional<T>::reference_const_type v) {
|
||||
return x.get_value_or(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline typename sprout::optional<T>::reference_type
|
||||
get_optional_value_or(sprout::optional<T>& x, typename sprout::optional<T>::reference_type v) {
|
||||
return x.get_value_or(v);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_OPTIONAL_GET_HPP
|
Loading…
Add table
Add a link
Reference in a new issue