1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/random/detail/ptr_helper.hpp

80 lines
2.3 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
2015-01-10 10:13:57 +00:00
Copyright (c) 2011-2015 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)
=============================================================================*/
2011-10-12 20:28:33 +00:00
#ifndef SPROUT_RANDOM_DETAIL_PTR_HELPER_HPP
#define SPROUT_RANDOM_DETAIL_PTR_HELPER_HPP
#include <sprout/config.hpp>
namespace sprout {
namespace random {
namespace detail {
template<typename T>
struct ptr_helper {
typedef T value_type;
typedef T& reference_type;
typedef T const& const_reference_type;
typedef T const& rvalue_type;
static reference_type ref(T& r) {
return r;
}
static SPROUT_CONSTEXPR const_reference_type ref(T const& r) {
return r;
}
};
template<typename T>
struct ptr_helper<T&> {
typedef T value_type;
typedef T& reference_type;
typedef T const& const_reference_type;
typedef T& rvalue_type;
static reference_type ref(T& r) {
return r;
}
static SPROUT_CONSTEXPR const_reference_type ref(T const& r) {
return r;
}
};
template<typename T>
struct ptr_helper<T const&> {
typedef T value_type;
typedef T const& reference_type;
typedef T const& const_reference_type;
typedef T const& rvalue_type;
static SPROUT_CONSTEXPR const_reference_type ref(T const& r) {
return r;
}
};
template<typename T>
struct ptr_helper<T*> {
typedef T value_type;
typedef T& reference_type;
typedef T const& const_reference_type;
typedef T* rvalue_type;
static reference_type ref(T* p) {
return *p;
}
static SPROUT_CONSTEXPR const_reference_type ref(T const* p) {
return *p;
}
};
template<typename T>
struct ptr_helper<T const*> {
typedef T value_type;
typedef T const& reference_type;
typedef T const& const_reference_type;
typedef T const* rvalue_type;
static SPROUT_CONSTEXPR const_reference_type ref(T const* p) {
return *p;
}
};
} // namespace detail
} // namespace random
} // namespace sprout
2013-03-22 05:24:19 +00:00
#endif // #ifndef SPROUT_RANDOM_DETAIL_PTR_HELPER_HPP