Reputation: 7542
How would you compare strings when the characters (
and )
should come after the alphanumeric characters. Do I have to write a function or is there any library function available?
Thank you for your answers!
Upvotes: 1
Views: 235
Reputation: 180050
You can use std::lexicographical_compare
with a custom predicate. That predicate should take 2 chars, and return false if the first should come before the second.
Upvotes: 2
Reputation: 1158
(
and )
with characters that come after alphanumeric characters in the particular encoding you're usingFor instance, (
and )
come before alphanumeric characters in ASCII, but {
and }
come after!
Upvotes: 1
Reputation: 96291
There's no built in way to do this. You'll have to write your own comparison function/functor. I believe you can however implement this with character traits so that operator<
still works, but you won't be using std::string
anymore.
Upvotes: 1
Reputation: 1786
some environments have provision for custom collation sequences, but generally speaking you have to write your own.
Upvotes: 0