add compost some ranges.

This commit is contained in:
bolero-MURAKAMI 2012-11-24 15:57:50 +09:00
parent cc4ade67fd
commit 05f75bef27
19 changed files with 289 additions and 13 deletions

View file

@ -2,7 +2,20 @@
#define SPROUT_COMPOST_RANGES_HPP
#include <sprout/config.hpp>
#include <sprout/compost/ranges/jointed.hpp>
#include <sprout/compost/ranges/copied.hpp>
#include <sprout/compost/ranges/piped.hpp>
#include <sprout/compost/ranges/taken.hpp>
#include <sprout/compost/ranges/taken_end.hpp>
#include <sprout/compost/ranges/dropped.hpp>
#include <sprout/compost/ranges/dropped_end.hpp>
#include <sprout/compost/ranges/window.hpp>
#include <sprout/compost/ranges/offset.hpp>
#include <sprout/compost/ranges/adapted_taken.hpp>
#include <sprout/compost/ranges/adapted_taken_end.hpp>
#include <sprout/compost/ranges/adapted_dropped.hpp>
#include <sprout/compost/ranges/adapted_dropped_end.hpp>
#include <sprout/compost/ranges/adapted_window.hpp>
#include <sprout/compost/ranges/adapted_offset.hpp>
#include <sprout/compost/ranges/jointed.hpp>
#endif // #ifndef SPROUT_COMPOST_RANGES_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_HPP
#define SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/adapted_dropped.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// adapted_dropped
//
using sprout::adaptors::adapted_dropped;
} // namespace ranges
using sprout::compost::ranges::adapted_dropped;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_END_HPP
#define SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_END_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/adapted_dropped_end.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// adapted_dropped_end
//
using sprout::adaptors::adapted_dropped_end;
} // namespace ranges
using sprout::compost::ranges::adapted_dropped_end;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_END_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_ADAPTED_OFFSET_HPP
#define SPROUT_COMPOST_RANGES_ADAPTED_OFFSET_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/adapted_offset.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// adapted_offset
//
using sprout::adaptors::adapted_offset;
} // namespace ranges
using sprout::compost::ranges::adapted_offset;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_ADAPTED_OFFSET_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_HPP
#define SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/adapted_taken.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// adapted_taken
//
using sprout::adaptors::adapted_taken;
} // namespace ranges
using sprout::compost::ranges::adapted_taken;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_END_HPP
#define SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_END_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/adapted_taken_end.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// adapted_taken_end
//
using sprout::adaptors::adapted_taken_end;
} // namespace ranges
using sprout::compost::ranges::adapted_taken_end;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_END_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_ADAPTED_WINDOW_HPP
#define SPROUT_COMPOST_RANGES_ADAPTED_WINDOW_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/adapted_window.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// adapted_window
//
using sprout::adaptors::adapted_window;
} // namespace ranges
using sprout::compost::ranges::adapted_window;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_ADAPTED_WINDOW_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_DROPPED_HPP
#define SPROUT_COMPOST_RANGES_DROPPED_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/dropped.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// dropped
//
using sprout::adaptors::dropped;
} // namespace ranges
using sprout::compost::ranges::dropped;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_DROPPED_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_DROPPED_END_HPP
#define SPROUT_COMPOST_RANGES_DROPPED_END_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/dropped_end.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// dropped_end
//
using sprout::adaptors::dropped_end;
} // namespace ranges
using sprout::compost::ranges::dropped_end;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_DROPPED_END_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_OFFSET_HPP
#define SPROUT_COMPOST_RANGES_OFFSET_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/offset.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// offset
//
using sprout::adaptors::offset;
} // namespace ranges
using sprout::compost::ranges::offset;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_OFFSET_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_PIPED_HPP
#define SPROUT_COMPOST_RANGES_PIPED_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/piped.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// piped
//
using sprout::adaptors::piped;
} // namespace ranges
using sprout::compost::ranges::piped;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_PIPED_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_TAKEN_HPP
#define SPROUT_COMPOST_RANGES_TAKEN_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/taken.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// taken
//
using sprout::adaptors::taken;
} // namespace ranges
using sprout::compost::ranges::taken;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_TAKEN_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_TAKEN_END_HPP
#define SPROUT_COMPOST_RANGES_TAKEN_END_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/taken_end.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// taken_end
//
using sprout::adaptors::taken_end;
} // namespace ranges
using sprout::compost::ranges::taken_end;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_TAKEN_END_HPP

View file

@ -0,0 +1,20 @@
#ifndef SPROUT_COMPOST_RANGES_WINDOW_HPP
#define SPROUT_COMPOST_RANGES_WINDOW_HPP
#include <sprout/config.hpp>
#include <sprout/range/adaptor/window.hpp>
namespace sprout {
namespace compost {
namespace ranges {
//
// window
//
using sprout::adaptors::window;
} // namespace ranges
using sprout::compost::ranges::window;
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_RANGES_WINDOW_HPP

View file

@ -52,7 +52,9 @@ namespace sprout {
template<typename... Elems>
SPROUT_CONSTEXPR sound_type(info_type const& info, Elems const&... elems)
: elements_{{
(static_cast<typename std::make_signed<Elems>::type>(elems) / static_cast<value_type>(32768.0))...
(info.bits_per_sample == 8 ? elems / static_cast<value_type>(0x80) - 1
: elems / static_cast<value_type>(0x8000)
)...
}}
{
static_assert(sizeof...(Elems) == static_size, "sound_type<>: unmatch source size");

View file

@ -52,13 +52,13 @@ namespace sprout {
iterator(sprout::end(range), low, up, comp)
)
{}
SPROUT_CONSTEXPR compare_type const& compare() const {
SPROUT_CONSTEXPR compare_type compare() const {
return base_type::begin().compare();
}
SPROUT_CONSTEXPR value_type const& lower() const {
SPROUT_CONSTEXPR value_type lower() const {
return base_type::begin().lower();
}
SPROUT_CONSTEXPR value_type const& upper() const {
SPROUT_CONSTEXPR value_type upper() const {
return base_type::begin().upper();
}
};

View file

@ -2,6 +2,7 @@
#define SPROUT_RANGE_ADAPTOR_PIPED_HPP
#include <type_traits>
#include <utility>
#include <sprout/config.hpp>
#include <sprout/index_tuple.hpp>
#include <sprout/utility/forward.hpp>
@ -88,9 +89,9 @@ namespace sprout {
template<typename Range>
SPROUT_CONSTEXPR auto
apply(Range&& range) const
-> decltype(sprout::adaptors::detail::apply_adaptors_tuple(sprout::forward<Range>(range), adaptors_))
-> decltype(sprout::adaptors::detail::apply_adaptors_tuple(sprout::forward<Range>(range), std::declval<pipe_holder const&>().adaptors()))
{
return sprout::adaptors::detail::apply_adaptors_tuple(sprout::forward<Range>(range), adaptors_);
return sprout::adaptors::detail::apply_adaptors_tuple(sprout::forward<Range>(range), adaptors());
}
};

View file

@ -29,7 +29,7 @@ namespace sprout {
: old_(old_value)
, new_(new_value)
{}
SPROUT_CONSTEXPR T const& operator()(T const& value) const {
SPROUT_CONSTEXPR T operator()(T const& value) const {
return (value == old_) ? new_ : value;
}
};
@ -84,10 +84,10 @@ namespace sprout {
: old_(old_value)
, new_(new_value)
{}
SPROUT_CONSTEXPR value_type old_value() const {
SPROUT_CONSTEXPR value_type const& old_value() const {
return old_;
}
SPROUT_CONSTEXPR value_type new_value() const {
SPROUT_CONSTEXPR value_type const& new_value() const {
return new_;
}
};

View file

@ -30,7 +30,7 @@ namespace sprout {
: pred_(pred)
, new_(new_value)
{}
SPROUT_CONSTEXPR T const& operator()(T const& value) const {
SPROUT_CONSTEXPR T operator()(T const& value) const {
return pred_(value) ? new_ : value;
}
};
@ -86,10 +86,10 @@ namespace sprout {
: pred_(pred)
, new_(new_value)
{}
SPROUT_CONSTEXPR predicate_type predicate() const {
SPROUT_CONSTEXPR predicate_type const& predicate() const {
return pred_;
}
SPROUT_CONSTEXPR value_type new_value() const {
SPROUT_CONSTEXPR value_type const& new_value() const {
return new_;
}
};