From 7da0aa034369c62b019643824b80c1f8e81e861e Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sat, 24 Nov 2012 23:28:07 +0900 Subject: [PATCH] add compost left_channel, right_channel --- sprout/compost/formats.hpp | 2 ++ sprout/compost/formats/left_channel.hpp | 44 ++++++++++++++++++++++++ sprout/compost/formats/right_channel.hpp | 44 ++++++++++++++++++++++++ sprout/utility/lvalue_forward.hpp | 2 +- 4 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 sprout/compost/formats/left_channel.hpp create mode 100644 sprout/compost/formats/right_channel.hpp diff --git a/sprout/compost/formats.hpp b/sprout/compost/formats.hpp index ae2a9fbe..a292ad3f 100644 --- a/sprout/compost/formats.hpp +++ b/sprout/compost/formats.hpp @@ -3,5 +3,7 @@ #include #include +#include +#include #endif // #ifndef SPROUT_COMPOST_FORMATS_HPP diff --git a/sprout/compost/formats/left_channel.hpp b/sprout/compost/formats/left_channel.hpp new file mode 100644 index 00000000..e5323daf --- /dev/null +++ b/sprout/compost/formats/left_channel.hpp @@ -0,0 +1,44 @@ +#ifndef SPROUT_COMPOST_FORMATS_LEFT_CHANNEL_HPP +#define SPROUT_COMPOST_FORMATS_LEFT_CHANNEL_HPP + +#include +#include +#include + +namespace sprout { + namespace compost { + namespace formats { + // + // left_channel_forwarder + // + class left_channel_forwarder {}; + + // + // left_channel + // + namespace { + SPROUT_STATIC_CONSTEXPR sprout::compost::formats::left_channel_forwarder left_channel{}; + } // anonymous-namespace + + // + // operator| + // + template + inline SPROUT_CONSTEXPR auto + operator|(Range&& lhs, left_channel_forwarder const& rhs) + -> decltype( + sprout::forward(lhs) + | sprout::adaptors::steps(2) + ) + { + return sprout::forward(lhs) + | sprout::adaptors::steps(2) + ; + } + } // namespace formats + + using sprout::compost::formats::left_channel; + } // namespace compost +} // namespace sprout + +#endif // #ifndef SPROUT_COMPOST_FORMATS_LEFT_CHANNEL_HPP diff --git a/sprout/compost/formats/right_channel.hpp b/sprout/compost/formats/right_channel.hpp new file mode 100644 index 00000000..a05fe745 --- /dev/null +++ b/sprout/compost/formats/right_channel.hpp @@ -0,0 +1,44 @@ +#ifndef SPROUT_COMPOST_FORMATS_RIGHT_CHANNEL_HPP +#define SPROUT_COMPOST_FORMATS_RIGHT_CHANNEL_HPP + +#include +#include +#include + +namespace sprout { + namespace compost { + namespace formats { + // + // right_channel_forwarder + // + class right_channel_forwarder {}; + + // + // right_channel + // + namespace { + SPROUT_STATIC_CONSTEXPR sprout::compost::formats::right_channel_forwarder right_channel{}; + } // anonymous-namespace + + // + // operator| + // + template + inline SPROUT_CONSTEXPR auto + operator|(Range&& lhs, right_channel_forwarder const& rhs) + -> decltype( + sprout::forward(lhs) + | sprout::adaptors::steps(2, 1) + ) + { + return sprout::forward(lhs) + | sprout::adaptors::steps(2, 1) + ; + } + } // namespace formats + + using sprout::compost::formats::right_channel; + } // namespace compost +} // namespace sprout + +#endif // #ifndef SPROUT_COMPOST_FORMATS_RIGHT_CHANNEL_HPP diff --git a/sprout/utility/lvalue_forward.hpp b/sprout/utility/lvalue_forward.hpp index 236212f6..0b4bd983 100644 --- a/sprout/utility/lvalue_forward.hpp +++ b/sprout/utility/lvalue_forward.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include namespace sprout { //