mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-02 14:04:20 +00:00
random/bernoulli_distribution.hpp 追加
string.hpp 修正
This commit is contained in:
parent
ba79d0b42d
commit
99f1a4f741
10 changed files with 384 additions and 28 deletions
|
@ -6,7 +6,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/algorithm/fixed/result_of.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
@ -82,7 +82,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) < offset
|
||||
return sizeof...(Args) < static_cast<std::size_t>(offset)
|
||||
? generate_impl_3<InitSize>(cont, gen, offset, args..., call_gen<InitSize, Container>(gen, args...))
|
||||
: generate_impl_4(cont, args...)
|
||||
;
|
||||
|
@ -161,7 +161,7 @@ namespace sprout {
|
|||
Args const&... args
|
||||
)
|
||||
{
|
||||
return sizeof...(Args) - InitSize < offset
|
||||
return sizeof...(Args) - InitSize < static_cast<std::size_t>(offset)
|
||||
? generate_impl_1<InitSize>(cont, gen, offset, size, args..., *sprout::next(sprout::fixed_begin(cont), sizeof...(Args) - InitSize))
|
||||
: generate_impl_2<InitSize>(cont, gen, offset, size, InitSize, args...)
|
||||
;
|
||||
|
|
7
sprout/algorithm/string.hpp
Normal file
7
sprout/algorithm/string.hpp
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef SPROUT_ALGORITHM_STRING_HPP
|
||||
#define SPROUT_ALGORITHM_STRING_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/string/join.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_STRING_HPP
|
108
sprout/algorithm/string/join.hpp
Normal file
108
sprout/algorithm/string/join.hpp
Normal file
|
@ -0,0 +1,108 @@
|
|||
#ifndef SPROUT_ALGORITHM_STRING_JOIN_HPP
|
||||
#define SPROUT_ALGORITHM_STRING_JOIN_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/fixed_container/traits.hpp>
|
||||
#include <sprout/fixed_container/functions.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/operation/fixed/append_back.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace algorithm {
|
||||
namespace result_of {
|
||||
//
|
||||
// join
|
||||
//
|
||||
template<typename ContainerContainer, typename Separator>
|
||||
struct join {
|
||||
public:
|
||||
typedef typename sprout::rebind_fixed_size<
|
||||
typename sprout::fixed_container_traits<ContainerContainer>::value_type
|
||||
>::template apply<
|
||||
sprout::fixed_container_traits<ContainerContainer>::fixed_size != 0
|
||||
? (
|
||||
sprout::fixed_container_traits<
|
||||
typename sprout::fixed_container_traits<ContainerContainer>::value_type
|
||||
>::fixed_size
|
||||
+ (sprout::fixed_container_traits<ContainerContainer>::fixed_size - 1) * (
|
||||
sprout::fixed_container_traits<Separator>::fixed_size
|
||||
+ sprout::fixed_container_traits<
|
||||
typename sprout::fixed_container_traits<ContainerContainer>::value_type
|
||||
>::fixed_size
|
||||
)
|
||||
)
|
||||
: 0
|
||||
>::type type;
|
||||
};
|
||||
} // namespace result_of
|
||||
|
||||
namespace detail {
|
||||
template<typename Result, typename ContainerIterator, typename Separator, typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size == sprout::fixed_container_traits<Result>::fixed_size),
|
||||
Result
|
||||
>::type join_impl_1(
|
||||
ContainerIterator first,
|
||||
ContainerIterator last,
|
||||
Separator const& separator,
|
||||
Container const& current
|
||||
)
|
||||
{
|
||||
return current;
|
||||
}
|
||||
template<typename Result, typename ContainerIterator, typename Separator, typename Container>
|
||||
SPROUT_CONSTEXPR inline typename std::enable_if<
|
||||
(sprout::fixed_container_traits<Container>::fixed_size < sprout::fixed_container_traits<Result>::fixed_size),
|
||||
Result
|
||||
>::type join_impl_1(
|
||||
ContainerIterator first,
|
||||
ContainerIterator last,
|
||||
Separator const& separator,
|
||||
Container const& current
|
||||
)
|
||||
{
|
||||
return sprout::algorithm::detail::join_impl_1<Result>(
|
||||
sprout::next(first),
|
||||
last,
|
||||
separator,
|
||||
sprout::fixed::append_back(sprout::fixed::append_back(current, separator), *first)
|
||||
);
|
||||
}
|
||||
template<typename Result, typename ContainerIterator, typename Separator>
|
||||
SPROUT_CONSTEXPR inline Result join_impl(
|
||||
ContainerIterator first,
|
||||
ContainerIterator last,
|
||||
Separator const& separator
|
||||
)
|
||||
{
|
||||
return first != last
|
||||
? sprout::algorithm::detail::join_impl_1<Result>(
|
||||
sprout::next(first),
|
||||
last,
|
||||
separator,
|
||||
*first
|
||||
)
|
||||
: sprout::make_clone<Result>()
|
||||
;
|
||||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// join
|
||||
//
|
||||
template<typename ContainerContainer, typename Separator>
|
||||
SPROUT_CONSTEXPR inline typename sprout::algorithm::result_of::join<ContainerContainer, Separator>::type join(
|
||||
ContainerContainer const& cont_cont,
|
||||
Separator const& separator
|
||||
)
|
||||
{
|
||||
return sprout::algorithm::detail::join_impl<typename sprout::algorithm::result_of::join<ContainerContainer, Separator>::type>(
|
||||
sprout::begin(cont_cont),
|
||||
sprout::end(cont_cont),
|
||||
separator
|
||||
);
|
||||
}
|
||||
} // namespace algorithm
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_STRING_JOIN_HPP
|
Loading…
Add table
Add a link
Reference in a new issue