diff --git a/sprout/compost/ranges.hpp b/sprout/compost/ranges.hpp index 3a449dd6..0394b2bd 100644 --- a/sprout/compost/ranges.hpp +++ b/sprout/compost/ranges.hpp @@ -2,7 +2,20 @@ #define SPROUT_COMPOST_RANGES_HPP #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // #ifndef SPROUT_COMPOST_RANGES_HPP diff --git a/sprout/compost/ranges/adapted_dropped.hpp b/sprout/compost/ranges/adapted_dropped.hpp new file mode 100644 index 00000000..4477f528 --- /dev/null +++ b/sprout/compost/ranges/adapted_dropped.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_HPP +#define SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/adapted_dropped_end.hpp b/sprout/compost/ranges/adapted_dropped_end.hpp new file mode 100644 index 00000000..01b25670 --- /dev/null +++ b/sprout/compost/ranges/adapted_dropped_end.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_END_HPP +#define SPROUT_COMPOST_RANGES_ADAPTED_DROPPED_END_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/adapted_offset.hpp b/sprout/compost/ranges/adapted_offset.hpp new file mode 100644 index 00000000..29bc820e --- /dev/null +++ b/sprout/compost/ranges/adapted_offset.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_ADAPTED_OFFSET_HPP +#define SPROUT_COMPOST_RANGES_ADAPTED_OFFSET_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/adapted_taken.hpp b/sprout/compost/ranges/adapted_taken.hpp new file mode 100644 index 00000000..8154220b --- /dev/null +++ b/sprout/compost/ranges/adapted_taken.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_HPP +#define SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/adapted_taken_end.hpp b/sprout/compost/ranges/adapted_taken_end.hpp new file mode 100644 index 00000000..0f11be16 --- /dev/null +++ b/sprout/compost/ranges/adapted_taken_end.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_END_HPP +#define SPROUT_COMPOST_RANGES_ADAPTED_TAKEN_END_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/adapted_window.hpp b/sprout/compost/ranges/adapted_window.hpp new file mode 100644 index 00000000..00706eaf --- /dev/null +++ b/sprout/compost/ranges/adapted_window.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_ADAPTED_WINDOW_HPP +#define SPROUT_COMPOST_RANGES_ADAPTED_WINDOW_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/dropped.hpp b/sprout/compost/ranges/dropped.hpp new file mode 100644 index 00000000..22ebee58 --- /dev/null +++ b/sprout/compost/ranges/dropped.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_DROPPED_HPP +#define SPROUT_COMPOST_RANGES_DROPPED_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/dropped_end.hpp b/sprout/compost/ranges/dropped_end.hpp new file mode 100644 index 00000000..581f3f8b --- /dev/null +++ b/sprout/compost/ranges/dropped_end.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_DROPPED_END_HPP +#define SPROUT_COMPOST_RANGES_DROPPED_END_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/offset.hpp b/sprout/compost/ranges/offset.hpp new file mode 100644 index 00000000..2d16eff3 --- /dev/null +++ b/sprout/compost/ranges/offset.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_OFFSET_HPP +#define SPROUT_COMPOST_RANGES_OFFSET_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/piped.hpp b/sprout/compost/ranges/piped.hpp new file mode 100644 index 00000000..f9dbdb17 --- /dev/null +++ b/sprout/compost/ranges/piped.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_PIPED_HPP +#define SPROUT_COMPOST_RANGES_PIPED_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/taken.hpp b/sprout/compost/ranges/taken.hpp new file mode 100644 index 00000000..4e5dbc2e --- /dev/null +++ b/sprout/compost/ranges/taken.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_TAKEN_HPP +#define SPROUT_COMPOST_RANGES_TAKEN_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/taken_end.hpp b/sprout/compost/ranges/taken_end.hpp new file mode 100644 index 00000000..a913705d --- /dev/null +++ b/sprout/compost/ranges/taken_end.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_TAKEN_END_HPP +#define SPROUT_COMPOST_RANGES_TAKEN_END_HPP + +#include +#include + +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 diff --git a/sprout/compost/ranges/window.hpp b/sprout/compost/ranges/window.hpp new file mode 100644 index 00000000..0265354b --- /dev/null +++ b/sprout/compost/ranges/window.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_COMPOST_RANGES_WINDOW_HPP +#define SPROUT_COMPOST_RANGES_WINDOW_HPP + +#include +#include + +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 diff --git a/sprout/compost/sources/source.hpp b/sprout/compost/sources/source.hpp index 5a8c0aeb..3211d504 100644 --- a/sprout/compost/sources/source.hpp +++ b/sprout/compost/sources/source.hpp @@ -52,7 +52,9 @@ namespace sprout { template SPROUT_CONSTEXPR sound_type(info_type const& info, Elems const&... elems) : elements_{{ - (static_cast::type>(elems) / static_cast(32768.0))... + (info.bits_per_sample == 8 ? elems / static_cast(0x80) - 1 + : elems / static_cast(0x8000) + )... }} { static_assert(sizeof...(Elems) == static_size, "sound_type<>: unmatch source size"); diff --git a/sprout/range/adaptor/clamped.hpp b/sprout/range/adaptor/clamped.hpp index 90023aad..31699e18 100644 --- a/sprout/range/adaptor/clamped.hpp +++ b/sprout/range/adaptor/clamped.hpp @@ -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(); } }; diff --git a/sprout/range/adaptor/piped.hpp b/sprout/range/adaptor/piped.hpp index 2844bbff..86c639ef 100644 --- a/sprout/range/adaptor/piped.hpp +++ b/sprout/range/adaptor/piped.hpp @@ -2,6 +2,7 @@ #define SPROUT_RANGE_ADAPTOR_PIPED_HPP #include +#include #include #include #include @@ -88,9 +89,9 @@ namespace sprout { template SPROUT_CONSTEXPR auto apply(Range&& range) const - -> decltype(sprout::adaptors::detail::apply_adaptors_tuple(sprout::forward(range), adaptors_)) + -> decltype(sprout::adaptors::detail::apply_adaptors_tuple(sprout::forward(range), std::declval().adaptors())) { - return sprout::adaptors::detail::apply_adaptors_tuple(sprout::forward(range), adaptors_); + return sprout::adaptors::detail::apply_adaptors_tuple(sprout::forward(range), adaptors()); } }; diff --git a/sprout/range/adaptor/replaced.hpp b/sprout/range/adaptor/replaced.hpp index e847c3bb..d3fee314 100644 --- a/sprout/range/adaptor/replaced.hpp +++ b/sprout/range/adaptor/replaced.hpp @@ -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_; } }; diff --git a/sprout/range/adaptor/replaced_if.hpp b/sprout/range/adaptor/replaced_if.hpp index 38901f6a..f59e08cd 100644 --- a/sprout/range/adaptor/replaced_if.hpp +++ b/sprout/range/adaptor/replaced_if.hpp @@ -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_; } };