1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-10-05 13:00:00 +00:00

[desuructive changes] container traits new interface [破壊的変更]

This commit is contained in:
bolero-MURAKAMI 2012-03-31 16:24:13 +09:00
commit ad60c8c530
356 changed files with 3183 additions and 3251 deletions

View file

@ -0,0 +1,43 @@
#ifndef SPROUT_CONTAINER_BEGIN_HPP
#define SPROUT_CONTAINER_BEGIN_HPP
#include <cstddef>
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
//
// begin
//
template<typename Container>
inline typename sprout::container_traits<Container>::iterator begin(Container& cont) {
return cont.begin();
}
template<typename T, std::size_t N>
inline typename sprout::container_traits<T[N]>::iterator begin(T (& arr)[N]) {
return arr;
}
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::container_traits<Container>::const_iterator begin(Container const& cont) {
return cont.begin();
}
template<typename T, std::size_t N>
SPROUT_CONSTEXPR inline typename sprout::container_traits<T const[N]>::const_iterator begin(T const (& arr)[N]) {
return arr;
}
//
// cbegin
//
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::container_traits<Container>::const_iterator cbegin(Container const& cont) {
return cont.begin();
}
template<typename T, std::size_t N>
SPROUT_CONSTEXPR inline typename sprout::container_traits<T const[N]>::const_iterator cbegin(T const (& arr)[N]) {
return arr;
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_BEGIN_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_CONST_ITERATOR_HPP
#define SPROUT_CONTAINER_CONST_ITERATOR_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// const_iterator
//
template<typename Container>
struct const_iterator {
public:
typedef typename sprout::container_traits<Container>::const_iterator type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_CONST_ITERATOR_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_CONST_POINTER_HPP
#define SPROUT_CONTAINER_CONST_POINTER_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// const_pointer
//
template<typename Container>
struct const_pointer {
public:
typedef typename sprout::container_traits<Container>::const_pointer type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_CONST_POINTER_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_CONST_REFERENCE_HPP
#define SPROUT_CONTAINER_CONST_REFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// const_reference
//
template<typename Container>
struct const_reference {
public:
typedef typename sprout::container_traits<Container>::const_reference type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_CONST_REFERENCE_HPP

View file

@ -0,0 +1,53 @@
#ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_CONSTRUCT_TRAITS_HPP
#define SPROUT_CONTAINER_CONTAINER_TRAITS_CONSTRUCT_TRAITS_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// container_construct_traits
//
template<typename Container>
struct container_construct_traits;
namespace detail {
template<typename Container, typename... Args>
SPROUT_CONSTEXPR typename sprout::container_construct_traits<Container>::copied_type
default_make_container(Args&&... args) {
typedef typename sprout::container_construct_traits<Container>::copied_type copied_type;
return copied_type{{sprout::forward<Args>(args)...}};
}
} // namespace detail
template<typename Container>
struct container_construct_traits {
public:
typedef Container copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::forward<Cont>(cont);
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::detail::default_make_container<Container>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<Container>::difference_type size,
Args&&... args
)
{
return make(sprout::forward<Args>(args)...);
}
};
template<typename Container>
struct container_construct_traits<Container const>
: public sprout::container_construct_traits<Container>
{};
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_CONSTRUCT_TRAITS_HPP

View file

@ -0,0 +1,98 @@
#ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
#define SPROUT_CONTAINER_CONTAINER_TRAITS_HPP
#include <cstddef>
#include <array>
#include <sprout/config.hpp>
namespace sprout {
//
// container_traits
//
template<typename Container>
struct container_traits;
namespace detail {
template<typename Container>
struct container_traits_default_types {
public:
typedef typename Container::value_type value_type;
typedef typename Container::iterator iterator;
typedef typename Container::const_iterator const_iterator;
typedef typename Container::reference reference;
typedef typename Container::const_reference const_reference;
typedef typename Container::size_type size_type;
typedef typename Container::difference_type difference_type;
typedef typename Container::pointer pointer;
typedef typename Container::const_pointer const_pointer;
};
template<typename T, std::size_t N>
struct container_traits_default_types<T[N]> {
public:
typedef T value_type;
typedef T* iterator;
typedef T const* const_iterator;
typedef T& reference;
typedef T const& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef T* pointer;
typedef T const* const_pointer;
};
template<typename Container>
struct container_traits_default_size {
public:
SPROUT_STATIC_CONSTEXPR typename sprout::detail::container_traits_default_types<Container>::size_type static_size
= std::tuple_size<Container>::value
;
public:
static SPROUT_CONSTEXPR typename sprout::detail::container_traits_default_types<Container>::size_type fixed_size() {
return static_size;
}
};
template<typename T, std::size_t N>
struct container_traits_default_size<T[N]> {
public:
SPROUT_STATIC_CONSTEXPR typename sprout::detail::container_traits_default_types<T[N]>::size_type static_size
= N
;
public:
static SPROUT_CONSTEXPR typename sprout::detail::container_traits_default_types<T[N]>::size_type fixed_size() {
return static_size;
}
};
} // namespace detail
template<typename Container>
struct container_traits
: public sprout::detail::container_traits_default_types<Container>
, public sprout::detail::container_traits_default_size<Container>
{};
template<typename Container>
struct container_traits<Container const>
: public sprout::container_traits<Container>
{
public:
typedef typename sprout::container_traits<Container>::const_iterator iterator;
typedef typename sprout::container_traits<Container>::const_reference reference;
typedef typename sprout::container_traits<Container>::const_pointer pointer;
};
template<typename T, std::size_t N>
struct container_traits<T[N]>
: public sprout::detail::container_traits_default_types<T[N]>
, public sprout::detail::container_traits_default_size<T[N]>
{};
template<typename T, std::size_t N>
struct container_traits<T const[N]>
: public sprout::container_traits<T[N]>
{
public:
typedef typename sprout::container_traits<T[N]>::const_iterator iterator;
typedef typename sprout::container_traits<T[N]>::const_reference reference;
typedef typename sprout::container_traits<T[N]>::const_pointer pointer;
};
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRAITS_HPP

View file

@ -0,0 +1,68 @@
#ifndef SPROUT_CONTAINER_CONTAINER_TRANSFORM_TRAITS_HPP
#define SPROUT_CONTAINER_CONTAINER_TRANSFORM_TRAITS_HPP
#include <cstddef>
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
//
// container_transform_traits
//
template<typename Container>
struct container_transform_traits;
namespace detail {
template<typename Container, typename sprout::container_traits<Container>::size_type Size>
struct default_array_rebind_size;
template<
template<typename, std::size_t> class Array,
typename T,
std::size_t N,
typename sprout::container_traits<Array<T, N> >::size_type Size
>
struct default_array_rebind_size<Array<T, N>, Size> {
public:
typedef Array<T, Size> type;
};
} // namespace detail
template<typename Container>
struct container_transform_traits {
public:
template<typename sprout::container_traits<Container>::size_type Size>
struct rebind_size
: public sprout::detail::default_array_rebind_size<Container, Size>
{};
};
template<typename Container>
struct container_transform_traits<Container const> {
public:
template<typename sprout::container_traits<Container>::size_type Size>
struct rebind_size {
typedef typename sprout::container_transform_traits<Container>::template rebind_size<Size>::type const type;
};
};
template<typename T, std::size_t N>
struct container_transform_traits<T[N]> {
public:
template<typename sprout::container_traits<T[N]>::size_type Size>
struct rebind_size {
public:
typedef T type[Size];
};
};
template<typename T, std::size_t N>
struct container_transform_traits<T const[N]> {
public:
template<typename sprout::container_traits<T const[N]>::size_type Size>
struct rebind_size {
public:
typedef T const type[Size];
};
};
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_TRANSFORM_TRAITS_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_COPIED_TYPE_HPP
#define SPROUT_CONTAINER_COPIED_TYPE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_construct_traits.hpp>
namespace sprout {
namespace containers {
//
// copied_type
//
template<typename Container>
struct copied_type {
public:
typedef typename sprout::container_construct_traits<Container>::copied_type type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_COPIED_TYPE_HPP

View file

@ -0,0 +1,22 @@
#ifndef SPROUT_CONTAINER_DEEP_COPY_HPP
#define SPROUT_CONTAINER_DEEP_COPY_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/container_construct_traits.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// deep_copy
//
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::container_construct_traits<
typename std::remove_reference<Container>::type
>::copied_type deep_copy(Container&& cont) {
typedef typename std::remove_reference<Container>::type container_type;
return sprout::container_construct_traits<container_type>::deep_copy(sprout::forward<Container>(cont));
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_DEEP_COPY_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_DIFFERENCE_TYPE_HPP
#define SPROUT_CONTAINER_DIFFERENCE_TYPE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// difference_type
//
template<typename Container>
struct difference_type {
public:
typedef typename sprout::container_traits<Container>::difference_type type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_DIFFERENCE_TYPE_HPP

View file

@ -0,0 +1,17 @@
#ifndef SPROUT_CONTAINER_EMPTY_HPP
#define SPROUT_CONTAINER_EMPTY_HPP
#include <sprout/config.hpp>
#include <sprout/container/size.hpp>
namespace sprout {
//
// empty
//
template<typename Container>
SPROUT_CONSTEXPR inline bool empty(Container const& cont) {
return sprout::size(cont) == 0;
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_EMPTY_HPP

43
sprout/container/end.hpp Normal file
View file

@ -0,0 +1,43 @@
#ifndef SPROUT_CONTAINER_END_HPP
#define SPROUT_CONTAINER_END_HPP
#include <cstddef>
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
//
// end
//
template<typename Container>
inline typename sprout::container_traits<Container>::iterator end(Container& cont) {
return cont.end();
}
template<typename T, std::size_t N>
inline typename sprout::container_traits<T[N]>::iterator end(T (& arr)[N]) {
return arr + N;
}
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::container_traits<Container>::const_iterator end(Container const& cont) {
return cont.end();
}
template<typename T, std::size_t N>
SPROUT_CONSTEXPR inline typename sprout::container_traits<T const[N]>::const_iterator end(T const (& arr)[N]) {
return arr + N;
}
//
// cend
//
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::container_traits<Container>::const_iterator cend(Container const& cont) {
return cont.end();
}
template<typename T, std::size_t N>
SPROUT_CONSTEXPR inline typename sprout::container_traits<T const[N]>::const_iterator cend(T const (& arr)[N]) {
return arr + N;
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_END_HPP

View file

@ -0,0 +1,17 @@
#ifndef SPROUT_CONTAINER_FIXED_SIZE_HPP
#define SPROUT_CONTAINER_FIXED_SIZE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
//
// fixed_size
//
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::container_traits<Container>::size_type fixed_size() {
return sprout::container_traits<Container>::fixed_size();
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_FIXED_SIZE_HPP

View file

@ -0,0 +1,22 @@
#ifndef SPROUT_CONTAINER_FUNCTIONS_HPP
#define SPROUT_CONTAINER_FUNCTIONS_HPP
#include <sprout/config.hpp>
#include <sprout/container/fixed_size.hpp>
#include <sprout/container/begin.hpp>
#include <sprout/container/end.hpp>
#include <sprout/container/size.hpp>
#include <sprout/container/empty.hpp>
#include <sprout/container/deep_copy.hpp>
#include <sprout/container/make.hpp>
#include <sprout/container/remake.hpp>
#include <sprout/container/get_internal.hpp>
#include <sprout/container/internal_begin.hpp>
#include <sprout/container/internal_end.hpp>
#include <sprout/container/internal_begin_offset.hpp>
#include <sprout/container/internal_end_offset.hpp>
#include <sprout/container/internal_begin_offset_backward.hpp>
#include <sprout/container/internal_end_offset_backward.hpp>
#include <sprout/container/internal_deep_copy.hpp>
#endif // #ifndef SPROUT_CONTAINER_FUNCTIONS_HPP

View file

@ -0,0 +1,21 @@
#ifndef SPROUT_FIXED_CONTAINER_GET_INTERNAL_HPP
#define SPROUT_FIXED_CONTAINER_GET_INTERNAL_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/sub_container_traits.hpp>
#include <sprout/container/internal.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// get_internal
//
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::containers::internal<Container>::type get_internal(Container&& cont) {
typedef typename std::remove_reference<Container>::type container_type;
return sprout::sub_container_traits<container_type>::get_internal(sprout::forward<Container>(cont));
}
} // namespace sprout
#endif // #ifndef SPROUT_FIXED_CONTAINER_GET_INTERNAL_HPP

View file

@ -0,0 +1,25 @@
#ifndef SPROUT_CONTAINER_INTERNAL_HPP
#define SPROUT_CONTAINER_INTERNAL_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/sub_container_traits.hpp>
namespace sprout {
namespace containers {
//
// internal
//
template<typename Container>
struct internal {
public:
typedef typename sprout::sub_container_traits<
typename std::remove_reference<Container>::type
>::template internal<
Container
>::type type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_INTERNAL_HPP

View file

@ -0,0 +1,46 @@
#ifndef SPROUT_CONTAINER_INTERNAL_BEGIN_HPP
#define SPROUT_CONTAINER_INTERNAL_BEGIN_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/container/sub_container_traits.hpp>
#include <sprout/container/internal.hpp>
#include <sprout/container/begin.hpp>
#include <sprout/container/get_internal.hpp>
namespace sprout {
//
// internal_begin
//
template<typename Container>
typename sprout::container_traits<
typename std::remove_reference<
typename sprout::containers::internal<Container&>::type
>::type
>::iterator internal_begin(Container& cont) {
return sprout::begin(sprout::get_internal(cont));
}
template<typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<
typename std::remove_reference<
typename sprout::containers::internal<Container const&>::type
>::type
>::const_iterator internal_begin(Container const& cont) {
return sprout::begin(sprout::get_internal(cont));
}
//
// internal_cbegin
//
template<typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<
typename std::remove_reference<
typename sprout::containers::internal<Container const&>::type
>::type
>::const_iterator internal_cbegin(Container const& cont) {
return sprout::begin(sprout::get_internal(cont));
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_INTERNAL_BEGIN_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_INTERNAL_BEGIN_OFFSET_HPP
#define SPROUT_CONTAINER_INTERNAL_BEGIN_OFFSET_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/container/begin.hpp>
#include <sprout/container/internal_begin.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
//
// internal_begin_offset
//
template<typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type internal_begin_offset(Container const& cont) {
return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::internal_begin(cont), sprout::begin(cont));
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_INTERNAL_BEGIN_OFFSET_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_INTERNAL_BEGIN_OFFSET_BACKWARD_HPP
#define SPROUT_CONTAINER_INTERNAL_BEGIN_OFFSET_BACKWARD_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/container/begin.hpp>
#include <sprout/container/internal_end.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
//
// internal_begin_offset_backward
//
template<typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type internal_begin_offset_backward(Container const& cont) {
return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), sprout::internal_end(cont));
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_INTERNAL_BEGIN_OFFSET_BACKWARD_HPP

View file

@ -0,0 +1,29 @@
#ifndef SPROUT_FIXED_CONTAINER_INTERNAL_DEEP_COPY_HPP
#define SPROUT_FIXED_CONTAINER_INTERNAL_DEEP_COPY_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/container_construct_traits.hpp>
#include <sprout/container/sub_container_traits.hpp>
#include <sprout/container/internal.hpp>
#include <sprout/container/deep_copy.hpp>
#include <sprout/container/get_internal.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// internal_deep_copy
//
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::container_construct_traits<
typename std::remove_reference<
typename sprout::containers::internal<Container>::type
>::type
>::copied_type internal_deep_copy(Container&& cont) {
return sprout::deep_copy(
sprout::get_internal(sprout::forward<Container>(cont))
);
}
} // namespace sprout
#endif // #ifndef SPROUT_FIXED_CONTAINER_INTERNAL_DEEP_COPY_HPP

View file

@ -0,0 +1,46 @@
#ifndef SPROUT_CONTAINER_INTERNAL_END_HPP
#define SPROUT_CONTAINER_INTERNAL_END_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/container/sub_container_traits.hpp>
#include <sprout/container/internal.hpp>
#include <sprout/container/end.hpp>
#include <sprout/container/get_internal.hpp>
namespace sprout {
//
// internal_end
//
template<typename Container>
typename sprout::container_traits<
typename std::remove_reference<
typename sprout::containers::internal<Container&>::type
>::type
>::iterator internal_end(Container& cont) {
return sprout::end(sprout::get_internal(cont));
}
template<typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<
typename std::remove_reference<
typename sprout::containers::internal<Container const&>::type
>::type
>::const_iterator internal_end(Container const& cont) {
return sprout::end(sprout::get_internal(cont));
}
//
// internal_cend
//
template<typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<
typename std::remove_reference<
typename sprout::containers::internal<Container const&>::type
>::type
>::const_iterator internal_cend(Container const& cont) {
return sprout::end(sprout::get_internal(cont));
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_INTERNAL_END_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_INTERNAL_END_OFFSET_HPP
#define SPROUT_CONTAINER_INTERNAL_END_OFFSET_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/container/end.hpp>
#include <sprout/container/internal_begin.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
//
// internal_end_offset
//
template<typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type internal_end_offset(Container const& cont) {
return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::internal_begin(cont), sprout::end(cont));
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_INTERNAL_END_OFFSET_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_INTERNAL_END_OFFSET_BACKWARD_HPP
#define SPROUT_CONTAINER_INTERNAL_END_OFFSET_BACKWARD_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/container/end.hpp>
#include <sprout/container/internal_end.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
//
// internal_end_offset_backward
//
template<typename Container>
SPROUT_CONSTEXPR typename sprout::container_traits<Container>::difference_type internal_end_offset_backward(Container const& cont) {
return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::end(cont), sprout::internal_end(cont));
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_INTERNAL_END_OFFSET_BACKWARD_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_ITERATOR_HPP
#define SPROUT_CONTAINER_ITERATOR_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// iterator
//
template<typename Container>
struct iterator {
public:
typedef typename sprout::container_traits<Container>::iterator type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_ITERATOR_HPP

18
sprout/container/make.hpp Normal file
View file

@ -0,0 +1,18 @@
#ifndef SPROUT_CONTAINER_MAKE_HPP
#define SPROUT_CONTAINER_MAKE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_construct_traits.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// make
//
template<typename Container, typename... Args>
SPROUT_CONSTEXPR inline typename sprout::container_construct_traits<Container>::copied_type make(Args&&... args) {
return sprout::container_construct_traits<Container>::make(sprout::forward<Args>(args)...);
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_MAKE_HPP

View file

@ -0,0 +1,19 @@
#ifndef SPROUT_CONTAINER_METAFUNCTIONS_HPP
#define SPROUT_CONTAINER_METAFUNCTIONS_HPP
#include <sprout/config.hpp>
#include <sprout/container/value_type.hpp>
#include <sprout/container/iterator.hpp>
#include <sprout/container/const_iterator.hpp>
#include <sprout/container/reference.hpp>
#include <sprout/container/const_reference.hpp>
#include <sprout/container/size_type.hpp>
#include <sprout/container/difference_type.hpp>
#include <sprout/container/pointer.hpp>
#include <sprout/container/const_pointer.hpp>
#include <sprout/container/static_size.hpp>
#include <sprout/container/copied_type.hpp>
#include <sprout/container/rebind_size.hpp>
#include <sprout/container/internal.hpp>
#endif // #ifndef SPROUT_CONTAINER_METAFUNCTIONS_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_POINTER_HPP
#define SPROUT_CONTAINER_POINTER_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// pointer
//
template<typename Container>
struct pointer {
public:
typedef typename sprout::container_traits<Container>::pointer type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_POINTER_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_REBIND_SIZE_HPP
#define SPROUT_CONTAINER_REBIND_SIZE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_transform_traits.hpp>
namespace sprout {
namespace containers {
//
// rebind_size
//
template<typename Container, typename sprout::container_traits<Container>::size_type Size>
struct rebind_size {
public:
typedef typename sprout::container_transform_traits<Container>::template rebind_size<Size>::type type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_REBIND_SIZE_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_REFERENCE_HPP
#define SPROUT_CONTAINER_REFERENCE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// reference
//
template<typename Container>
struct reference {
public:
typedef typename sprout::container_traits<Container>::reference type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_REFERENCE_HPP

View file

@ -0,0 +1,29 @@
#ifndef SPROUT_CONTAINER_REMAKE_HPP
#define SPROUT_CONTAINER_REMAKE_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/container/container_construct_traits.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// remake
//
template<typename Container, typename Cont, typename... Args>
SPROUT_CONSTEXPR inline typename sprout::container_construct_traits<Container>::copied_type remake(
Cont&& cont,
typename sprout::container_traits<Container>::difference_type size,
Args&&... args
)
{
return sprout::container_construct_traits<Container>::remake(
sprout::forward<Cont>(cont),
size,
sprout::forward<Args>(args)...
);
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_REMAKE_HPP

20
sprout/container/size.hpp Normal file
View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_SIZE_HPP
#define SPROUT_CONTAINER_SIZE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/container/begin.hpp>
#include <sprout/container/end.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL
namespace sprout {
//
// size
//
template<typename Container>
SPROUT_CONSTEXPR inline typename sprout::container_traits<Container>::difference_type size(Container const& cont) {
return NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance(sprout::begin(cont), sprout::end(cont));
}
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_SIZE_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_SIZE_TYPE_HPP
#define SPROUT_CONTAINER_SIZE_TYPE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// size_type
//
template<typename Container>
struct size_type {
public:
typedef typename sprout::container_traits<Container>::size_type type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_SIZE_TYPE_HPP

View file

@ -0,0 +1,23 @@
#ifndef SPROUT_CONTAINER_STATIC_SIZE_HPP
#define SPROUT_CONTAINER_STATIC_SIZE_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// static_size
//
template<typename Container>
struct static_size
: public std::integral_constant<
typename sprout::container_traits<Container>::size_type,
sprout::container_traits<Container>::static_size
>
{};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_STATIC_SIZE_HPP

View file

@ -0,0 +1,31 @@
#ifndef SPROUT_CONTAINER_SUB_CONTAINER_TRAITS_HPP
#define SPROUT_CONTAINER_SUB_CONTAINER_TRAITS_HPP
#include <sprout/config.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
//
// sub_container_traits
//
template<typename Container>
struct sub_container_traits {
public:
template<typename Cont>
struct internal {
public:
typedef Cont&& type;
};
public:
template<typename Cont>
static SPROUT_CONSTEXPR typename internal<Cont>::type get_internal(Cont&& cont) {
return sprout::forward<Cont>(cont);
}
};
template<typename Container>
struct sub_container_traits<Container const>
: public sprout::sub_container_traits<Container>
{};
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_SUB_CONTAINER_TRAITS_HPP

View file

@ -0,0 +1,10 @@
#ifndef SPROUT_CONTAINER_TRAITS_HPP
#define SPROUT_CONTAINER_TRAITS_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
#include <sprout/container/container_construct_traits.hpp>
#include <sprout/container/container_transform_traits.hpp>
#include <sprout/container/sub_container_traits.hpp>
#endif // #ifndef SPROUT_CONTAINER_TRAITS_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_CONTAINER_VALUE_TYPE_HPP
#define SPROUT_CONTAINER_VALUE_TYPE_HPP
#include <sprout/config.hpp>
#include <sprout/container/container_traits.hpp>
namespace sprout {
namespace containers {
//
// value_type
//
template<typename Container>
struct value_type {
public:
typedef typename sprout::container_traits<Container>::value_type type;
};
} // namespace containers
} // namespace sprout
#endif // #ifndef SPROUT_CONTAINER_VALUE_TYPE_HPP