Created
October 28, 2016 09:16
-
-
Save GamePad64/c8c66992e8586eef4aca870f5596210f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <algorithm> | |
template<typename _Iterator> | |
void reverse_wordwise_inplace(_Iterator first, _Iterator second) { | |
std::reverse(first, second); | |
_Iterator first_w = first; | |
_Iterator second_w = first; | |
do { | |
second_w = std::find(first_w, second, ' '); | |
std::reverse(first_w, second_w); | |
if(second_w != second) | |
first_w = ++second_w; | |
} while(second_w != second); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment