-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use iterators for split #14
Conversation
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mainly LGTM, a few nits
split(const std::string & input, char delim, bool skip_empty = false) | ||
template< | ||
class InsertIterator, | ||
typename std::enable_if< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could static_assert be used here instead to improve readability?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I opted for SFINAE is that static_assert
doesn't participate in function overloading. That being, the current template approach has the benefit of having another function declaration set with std::enable_if
which accepts a different form of iterator. One of them could be just a class member function, e.g. add
which takes the string and operates on it.
Does this make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that makes sense. I just feel it's hard to read and I wished there was a better way to write this, but I don't see any right now so this LGTM ;)
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
I hopefully addressed all your comments. I am happy to re-iterate over |
I am extending the current split implementation for a iterator based design. This allows to use the same functionality for split to be used in different containers (e.g.
std::list
,std::set
) and gives the opportunity for custom iterators. Especially the latter seems quite useful in order to correctly split and parse a message definition and extract it as a tuple.CI: (build: up-to rcpputils, test: packages-select rcpputils)
Signed-off-by: Karsten Knese karsten@openrobotics.org