mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
algorithm, operation 全面修正
This commit is contained in:
parent
21f5d5191a
commit
5e67195030
244 changed files with 4764 additions and 831 deletions
29
sprout/fixed_container/clone.hpp
Normal file
29
sprout/fixed_container/clone.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef SPROUT_FIXED_CONTAINER_CLONE_HPP
|
||||
#define SPROUT_FIXED_CONTAINER_CLONE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// clone
|
||||
//
|
||||
template<typename Container>
|
||||
inline typename sprout::fixed_container_traits<Container>::clone_type clone(Container& cont) {
|
||||
return sprout::clone_functor<Container>().template operator()(cont);
|
||||
}
|
||||
template<typename Container, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::clone_type clone(Container const& cont) {
|
||||
return sprout::clone_functor<Container>().template operator()(cont);
|
||||
}
|
||||
|
||||
//
|
||||
// cclone
|
||||
//
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::clone_type cclone(Container const& cont) {
|
||||
return sprout::clone_functor<Container>().template operator()(cont);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FIXED_CONTAINER_CLONE_HPP
|
|
@ -12,7 +12,7 @@ namespace sprout {
|
|||
template<typename Container>
|
||||
struct fixed_size {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::fixed_container_traits<Container>::size_type value
|
||||
typedef typename sprout::fixed_container_traits<Container>::size_type value
|
||||
= sprout::fixed_container_traits<Container>::fixed_size
|
||||
;
|
||||
typedef std::integral_constant<typename sprout::fixed_container_traits<Container>::size_type, value> type;
|
||||
|
|
|
@ -6,10 +6,13 @@
|
|||
#include <sprout/fixed_container/end.hpp>
|
||||
#include <sprout/fixed_container/size.hpp>
|
||||
#include <sprout/fixed_container/empty.hpp>
|
||||
#include <sprout/fixed_container/get_fixed.hpp>
|
||||
#include <sprout/fixed_container/fixed_begin.hpp>
|
||||
#include <sprout/fixed_container/fixed_end.hpp>
|
||||
#include <sprout/fixed_container/fixed_begin_offset.hpp>
|
||||
#include <sprout/fixed_container/fixed_end_offset.hpp>
|
||||
#include <sprout/fixed_container/get_fixed.hpp>
|
||||
#include <sprout/fixed_container/clone.hpp>
|
||||
#include <sprout/fixed_container/make_clone.hpp>
|
||||
#include <sprout/fixed_container/remake_clone.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FIXED_CONTAINER_FUNCTIONS_HPP
|
||||
|
|
|
@ -10,11 +10,11 @@ namespace sprout {
|
|||
//
|
||||
template<typename Container>
|
||||
inline typename sprout::fixed_container_traits<Container>::fixed_container_type& get_fixed(Container& cont) {
|
||||
return get_fixed_functor<Container>()(cont);
|
||||
return sprout::get_fixed_functor<Container>()(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::fixed_container_type const& get_fixed(Container const& cont) {
|
||||
return get_fixed_functor<Container>()(cont);
|
||||
return sprout::get_fixed_functor<Container>()(cont);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -22,7 +22,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::fixed_container_type const& get_cfixed(Container const& cont) {
|
||||
return get_fixed_functor<Container>()(cont);
|
||||
return sprout::get_fixed_functor<Container>()(cont);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -30,7 +30,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename Container>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::fixed_container_type get_fixed_copy(Container const& cont) {
|
||||
return get_fixed_functor<Container>()(cont);
|
||||
return sprout::get_fixed_functor<Container>()(cont);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
|
|
17
sprout/fixed_container/make_clone.hpp
Normal file
17
sprout/fixed_container/make_clone.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef SPROUT_FIXED_CONTAINER_MAKE_CLONE_HPP
|
||||
#define SPROUT_FIXED_CONTAINER_MAKE_CLONE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// make_clone
|
||||
//
|
||||
template<typename Container, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::clone_type make_clone(Args const&... args) {
|
||||
return sprout::make_clone_functor<Container>().template operator()(args...);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FIXED_CONTAINER_MAKE_CLONE_HPP
|
39
sprout/fixed_container/remake_clone.hpp
Normal file
39
sprout/fixed_container/remake_clone.hpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#ifndef SPROUT_FIXED_CONTAINER_REMAKE_CLONE_HPP
|
||||
#define SPROUT_FIXED_CONTAINER_REMAKE_CLONE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// remake_clone
|
||||
//
|
||||
template<typename Container, typename Other, typename... Args>
|
||||
inline typename sprout::fixed_container_traits<Container>::clone_type remake_clone(
|
||||
Other& other,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone_functor<Container>().template operator()(other, size, args...);
|
||||
}
|
||||
template<typename Container, typename Other, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::clone_type remake_clone(Other const& other, Args const&... args) {
|
||||
return sprout::remake_clone_functor<Container>().template operator()(other, args...);
|
||||
}
|
||||
|
||||
//
|
||||
// remake_cclone
|
||||
//
|
||||
template<typename Container, typename Other, typename... Args>
|
||||
SPROUT_CONSTEXPR inline typename sprout::fixed_container_traits<Container>::clone_type remake_cclone(
|
||||
Other const& other,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type size,
|
||||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sprout::remake_clone_functor<Container>().template operator()(other, size, args...);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FIXED_CONTAINER_REMAKE_CLONE_HPP
|
|
@ -45,9 +45,11 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
typedef Container fixed_container_type;
|
||||
typedef Container internal_type;
|
||||
typedef Container clone_type;
|
||||
public:
|
||||
static constexpr typename sprout::detail::fixed_container_traits_base<Container>::size_type fixed_size
|
||||
= std::tuple_size<typename std::remove_const<fixed_container_type>::type>::value
|
||||
SPROUT_STATIC_CONSTEXPR typename sprout::detail::fixed_container_traits_base<Container>::size_type fixed_size
|
||||
= std::tuple_size<typename std::remove_const<internal_type>::type>::value
|
||||
;
|
||||
};
|
||||
template<typename T, std::size_t N>
|
||||
|
@ -56,8 +58,10 @@ namespace sprout {
|
|||
{
|
||||
public:
|
||||
typedef T fixed_container_type[N];
|
||||
typedef T internal_type[N];
|
||||
typedef T clone_type[N];
|
||||
public:
|
||||
static constexpr typename sprout::detail::fixed_container_traits_base<T[N]>::size_type fixed_size = N;
|
||||
SPROUT_STATIC_CONSTEXPR typename sprout::detail::fixed_container_traits_base<T[N]>::size_type fixed_size = N;
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -92,6 +96,58 @@ namespace sprout {
|
|||
return cont;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// clone_functor
|
||||
//
|
||||
template<typename Container>
|
||||
struct clone_functor {
|
||||
public:
|
||||
typename sprout::fixed_container_traits<Container>::clone_type operator()(Container& cont) const {
|
||||
return typename sprout::fixed_container_traits<Container>::clone_type(cont);
|
||||
}
|
||||
SPROUT_CONSTEXPR typename sprout::fixed_container_traits<Container>::clone_type operator()(Container const& cont) const {
|
||||
return typename sprout::fixed_container_traits<Container>::clone_type(cont);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// make_clone_functor
|
||||
//
|
||||
template<typename Container>
|
||||
struct make_clone_functor {
|
||||
public:
|
||||
template<typename... Args>
|
||||
SPROUT_CONSTEXPR typename sprout::fixed_container_traits<Container>::clone_type operator()(Args const&... args) const {
|
||||
return typename sprout::fixed_container_traits<Container>::clone_type{args...};
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// remake_clone_functor
|
||||
//
|
||||
template<typename Container>
|
||||
struct remake_clone_functor {
|
||||
public:
|
||||
template<typename Other, typename... Args>
|
||||
typename sprout::fixed_container_traits<Container>::clone_type operator()(
|
||||
Other& other,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type size,
|
||||
Args const&... args
|
||||
) const
|
||||
{
|
||||
return sprout::make_clone_functor<Container>().template operator()(args...);
|
||||
}
|
||||
template<typename Other, typename... Args>
|
||||
SPROUT_CONSTEXPR typename sprout::fixed_container_traits<Container>::clone_type operator()(
|
||||
Other const& other,
|
||||
typename sprout::fixed_container_traits<Container>::difference_type size,
|
||||
Args const&... args
|
||||
) const
|
||||
{
|
||||
return sprout::make_clone_functor<Container>().template operator()(args...);
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FIXED_CONTAINER_TRAITS_HPP
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue