Created
August 22, 2019 18:27
-
-
Save Voltra/ac3aae80e647172d95106b735c01be73 to your computer and use it in GitHub Desktop.
C++ UFCS operator@
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
template <class Range> | |
Range firstHalf(const Range& r){ | |
auto&& begin = std::begin(r); | |
auto&& begin_ = begin; | |
return make<Range>( | |
begin, | |
std::next( | |
begin_, | |
std::distance(begin, std::end(r)) | |
) | |
); | |
} | |
int main(){ | |
std::vector<int> v = {0,1,2,3,4,5,6}; | |
assert(firstHalf(v) == v@firstHalf()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment