@@ -54,8 +54,11 @@ class joined_strings
54
54
ostringstream_typet;
55
55
56
56
public:
57
- joined_strings (It begin, const It end, const Str &sep)
58
- : begin(begin), end(end), sep(sep)
57
+ template <typename It_In, typename Str_In>
58
+ joined_strings (It_In &&begin, It_In &&end, Str_In &&sep)
59
+ : begin(std::forward<It_In>(begin)),
60
+ end (std::forward<It_In>(end)),
61
+ sep(std::forward<Str_In>(sep))
59
62
{
60
63
}
61
64
@@ -84,16 +87,19 @@ class joined_strings
84
87
85
88
86
89
template <typename Str, typename It>
87
- inline joined_strings<Str, It> join (It begin, const It end, const Str &sep)
90
+ inline joined_strings<Str, It> join (It begin, It end, const Str &sep)
88
91
{
89
- return joined_strings<Str, It>(begin, end, sep);
92
+ return joined_strings<Str, It>(std::move ( begin), std::move ( end) , sep);
90
93
}
91
94
92
95
template <typename It>
93
96
inline joined_strings<const char *, It> join (
94
- It begin, const It end, const char *sep)
97
+ It begin, It end, const char *sep)
95
98
{
96
- return joined_strings<const char *, It>(begin, end, sep);
99
+ return joined_strings<const char *, It>(
100
+ std::move (begin),
101
+ std::move (end),
102
+ sep);
97
103
}
98
104
99
105
@@ -105,10 +111,11 @@ class joined_strings_container
105
111
Container container;
106
112
107
113
public:
108
- joined_strings_container (const Container &container, const Str &sep)
114
+ template <typename Container_In, typename Str_In>
115
+ joined_strings_container (Container_In &&container, Str_In &&sep)
109
116
: joined_strings<Str, typename Container::const_iterator>(
110
- container.begin(), container.end(), sep),
111
- container (container)
117
+ container.begin(), container.end(), std::forward<Str_In>( sep) ),
118
+ container (std::forward<Container_In>( container) )
112
119
{
113
120
}
114
121
};
0 commit comments