1 // { dg-do run { target c++11 } }
5 #include <unordered_set>
9 #include <testsuite_hooks.h>
11 class TrimmedStr
: public std::string
13 static std::string
trim_str(std::string
const &str
)
15 auto start
= str
.find_first_not_of(" \r\n\t");
17 return start
== std::string::npos
19 : str
.substr(start
, str
.find_last_not_of(" \r\n\t") - start
+ 1);
23 TrimmedStr(std::string
const &arg
)
24 : std::string
{trim_str(arg
)} {}
25 TrimmedStr(char const *arg
)
26 : TrimmedStr
{std::string
{arg
}} {}
31 std::unordered_set
<TrimmedStr
, std::hash
<std::string
>, std::equal_to
<std::string
>>
32 set_from_initializer_list
{ "foo", "bar", " foo ", " bar " };
34 VERIFY( set_from_initializer_list
.size() == 2 );
36 std::vector
<std::string
> args
{ "foo", "bar", " foo ", " bar " };
37 std::unordered_set
<TrimmedStr
, std::hash
<std::string
>, std::equal_to
<std::string
>>
39 set_from_iterators
.insert(args
.begin(), args
.end());
40 VERIFY( set_from_iterators
.size() == 2 );