Sprout/sprout/optional/get.hpp

84 lines
2.9 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
2014-01-08 07:48:12 +00:00
Copyright (c) 2011-2014 Bolero MURAKAMI
2013-08-08 09:54:33 +00:00
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
2012-10-22 14:10:11 +00:00
#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_type
get(sprout::optional<T>& x) {
return sprout::optional<T>::get(x);
}
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::optional<T>::rvalue_reference_type
get(sprout::optional<T>&& x) {
return sprout::optional<T>::get(sprout::move(x));
}
template<typename T>
2012-10-22 14:10:11 +00:00
inline SPROUT_CONSTEXPR typename sprout::optional<T>::reference_const_type
get(sprout::optional<T> const& x) {
return sprout::optional<T>::get(x);
2012-10-22 14:10:11 +00:00
}
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::optional<T>::pointer_type
get(sprout::optional<T>* x) {
return sprout::optional<T>::get_pointer(*x);
2012-10-22 14:10:11 +00:00
}
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::optional<T>::pointer_const_type
get(sprout::optional<T> const* x) {
return sprout::optional<T>::get_pointer(*x);
2012-10-22 14:10:11 +00:00
}
//
// get_pointer
//
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::optional<T>::pointer_type
get_pointer(sprout::optional<T>& x) {
return sprout::optional<T>::get_pointer(x);
2012-10-22 14:10:11 +00:00
}
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::optional<T>::pointer_type
get_pointer(sprout::optional<T>&& x) {
return sprout::optional<T>::get_pointer(sprout::move(x));
}
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::optional<T>::pointer_const_type
get_pointer(sprout::optional<T> const& x) {
return sprout::optional<T>::get_pointer(x);
2012-10-22 14:10:11 +00:00
}
//
// get_value_or
2012-10-22 14:10:11 +00:00
//
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::optional<T>::reference_type
get_value_or(sprout::optional<T>& x, typename sprout::optional<T>::reference_type v) {
return sprout::optional<T>::get_value_or(x, v);
2012-10-22 14:10:11 +00:00
}
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::optional<T>::rvalue_reference_type
get_value_or(sprout::optional<T>&& x, typename sprout::optional<T>::rvalue_reference_type v) {
return sprout::optional<T>::get_value_or(sprout::move(x), static_cast<typename sprout::optional<T>::rvalue_reference_type>(v));
}
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::optional<T>::reference_const_type
get_value_or(sprout::optional<T> const& x, typename sprout::optional<T>::reference_const_type v) {
return sprout::optional<T>::get_value_or(x, v);
2012-10-22 14:10:11 +00:00
}
} // namespace sprout
#endif // #ifndef SPROUT_OPTIONAL_GET_HPP