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-06-16 06:35:10 +00:00
|
|
|
#ifndef SPROUT_CONTAINER_WEAK_REBIND_SIZE_HPP
|
|
|
|
#define SPROUT_CONTAINER_WEAK_REBIND_SIZE_HPP
|
|
|
|
|
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/config.hpp>
|
|
|
|
#include <sprout/container/container_transform_traits.hpp>
|
2013-11-22 12:11:08 +00:00
|
|
|
#include <sprout/type_traits/integral_constant.hpp>
|
2012-06-16 06:35:10 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace containers {
|
|
|
|
namespace detail {
|
|
|
|
template<
|
|
|
|
typename T,
|
|
|
|
template<typename sprout::container_traits<T>::size_type> class = T::template rebind_size
|
|
|
|
>
|
2013-11-22 12:11:08 +00:00
|
|
|
sprout::true_type sprout_has_xxx_impl_check_template_rebind_size(int);
|
2012-06-16 06:35:10 +00:00
|
|
|
template<typename T>
|
2013-11-22 12:11:08 +00:00
|
|
|
sprout::false_type sprout_has_xxx_impl_check_template_rebind_size(long);
|
2012-12-17 11:10:17 +00:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
template<typename T, typename Base_ = decltype(sprout::containers::detail::sprout_has_xxx_impl_check_template_rebind_size<T>(0))>
|
|
|
|
struct has_rebind_size
|
|
|
|
: public Base_
|
|
|
|
{};
|
|
|
|
#else
|
2012-06-16 06:35:10 +00:00
|
|
|
template<typename T>
|
|
|
|
struct has_rebind_size
|
2012-12-17 11:10:17 +00:00
|
|
|
: public decltype(sprout::containers::detail::sprout_has_xxx_impl_check_template_rebind_size<T>(0))
|
2012-06-16 06:35:10 +00:00
|
|
|
{};
|
2012-12-17 11:10:17 +00:00
|
|
|
#endif
|
2012-06-16 06:35:10 +00:00
|
|
|
} // namespace detail
|
|
|
|
//
|
|
|
|
// is_rebindable_size
|
|
|
|
//
|
|
|
|
template<typename Container>
|
|
|
|
struct is_rebindable_size
|
|
|
|
: public sprout::containers::detail::has_rebind_size<
|
|
|
|
sprout::container_transform_traits<Container>
|
|
|
|
>
|
|
|
|
{};
|
|
|
|
template<typename Container>
|
|
|
|
struct is_rebindable_size<Container const>
|
|
|
|
: public sprout::containers::is_rebindable_size<Container>
|
|
|
|
{};
|
|
|
|
template<typename Container>
|
|
|
|
struct is_rebindable_size<Container volatile>
|
|
|
|
: public sprout::containers::is_rebindable_size<Container>
|
|
|
|
{};
|
|
|
|
template<typename Container>
|
|
|
|
struct is_rebindable_size<Container const volatile>
|
|
|
|
: public sprout::containers::is_rebindable_size<Container>
|
|
|
|
{};
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
template<typename Container, typename sprout::container_traits<Container>::size_type Size, typename = void>
|
|
|
|
struct weak_rebind_size_impl;
|
|
|
|
template<typename Container, typename sprout::container_traits<Container>::size_type Size>
|
|
|
|
struct weak_rebind_size_impl<
|
|
|
|
Container, Size,
|
|
|
|
typename std::enable_if<sprout::containers::is_rebindable_size<Container>::value>::type
|
|
|
|
>
|
|
|
|
: public sprout::container_transform_traits<Container>::template rebind_size<Size>
|
|
|
|
{};
|
|
|
|
template<typename Container, typename sprout::container_traits<Container>::size_type Size>
|
|
|
|
struct weak_rebind_size_impl<
|
|
|
|
Container, Size,
|
|
|
|
typename std::enable_if<!sprout::containers::is_rebindable_size<Container>::value>::type
|
|
|
|
> {
|
|
|
|
public:
|
|
|
|
typedef Container type;
|
|
|
|
};
|
|
|
|
} // namespace detail
|
|
|
|
//
|
|
|
|
// weak_rebind_size
|
|
|
|
//
|
|
|
|
template<typename Container, typename sprout::container_traits<Container>::size_type Size>
|
|
|
|
struct weak_rebind_size
|
|
|
|
: public sprout::containers::detail::weak_rebind_size_impl<Container, Size>
|
|
|
|
{};
|
|
|
|
} // namespace containers
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_CONTAINER_WEAK_REBIND_SIZE_HPP
|