Last active
August 28, 2019 10:24
-
-
Save bradphelan/80fc63e7051a6bd71c15a6743400f02a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Handle lvalue sequence reference. | |
/// This means the lifetime of the input sequence should be longer than | |
/// the lifetime of the output sequence | |
template <typename Enumerable,typename Combinator> | |
auto | |
operator|(Enumerable & enumerable, Combinator c) -> | |
typename boost::enable_if_c | |
< MW_LINQ_IS_ENUMERABLE(Enumerable) && MW_LINQ_IS_LAZY_COMBINATOR(Combinator) | |
, EnumerableOp | |
< Combinator | |
, decltype(boost::make_iterator_range(enumerable)) | |
> | |
>::type | |
{ | |
return EnumerableOp | |
< typename std::decay<Combinator>::type | |
, decltype(boost::make_iterator_range(enumerable)) | |
> | |
(boost::make_iterator_range(enumerable), c); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Handle rvalue sequence reference. The sequence will | |
/// be moved into the operator. This is useful if you | |
/// wish to return a sequence from a function. If your | |
/// input sequence is an rvalue then it will get moved. | |
template <typename Enumerable,typename Combinator> | |
auto | |
operator|(Enumerable && enumerable, Combinator c) -> | |
typename boost::enable_if_c | |
< MW_LINQ_IS_ENUMERABLE(Enumerable) && MW_LINQ_IS_LAZY_COMBINATOR(Combinator) && !std::is_lvalue_reference<Enumerable>::value | |
, EnumerableOp | |
< Combinator | |
, Enumerable | |
> | |
>::type | |
{ | |
return EnumerableOp | |
< Combinator | |
, Enumerable | |
> | |
(std::move(enumerable), c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment