joboccara/pipes

Utility of `funnel` unclear

Closed this issue · 6 comments

I don't see any documentation about funnel. It like the library should be implementable without it and that it adds unnecessary syntactic overhead.

You're right. I was about to write how I couldn't make the library work without funnel, and the fact that you suggested that it seemed possible made give it another try.
And with this fix funnel is now gone! The fix is that operator>>= now uses the detection idiom to guess if the left operand looks like a range.
Thanks a bunch! :)

I haven't tested the fix, but it looks like it wouldn't work with types which have begin and end found through ADL.

TartanLlama is correct, it will not work with ADL begin and end. You need to do something like this:

namespace detail
{
namespace adl
{
using std::begin;
using std::end;
template<typename T>
using begin_expression = decltype(begin(std::declval<T&>()));
template<typename T>
using end_expression = decltype(end(std::declval<T&>()));
}
using adl::begin_expression;
using adl::end_expression;
template<typename Range>
constexpr bool range_expression_detected = detail::is_detected<begin_expression, Range> && detail::is_detected<end_expression, Range>;

I think it'd need to be std::declval<T&>, but otherwise looks legit.

Indeed, thanks. Fix submitted with this commit.

Looks good, should be std::declval<T&> though