@@ -155,6 +155,12 @@ namespace xtd {
155155 // / @{
156156 // / @brief Initializes a new instance of xtd::basic_string.
157157 basic_string () = default ;
158+ // / @brief Initializes a new instance of xtd::basic_string with specified string to move.
159+ // / @param str The basic_string to move.
160+ basic_string (basic_string&&) = default ;
161+ // / @brief Initializes a new instance of xtd::basic_string with specified string to move.
162+ // / @param str The basic_string to move.
163+ basic_string (std::basic_string<char_t >&& str) : chars_ {std::move (str)} {}
158164 // / @brief Initializes a new instance of xtd::basic_string with specified string to copy.
159165 // / @param str The string to copy.
160166 basic_string (const basic_string<char >& str) noexcept {
@@ -185,107 +191,36 @@ namespace xtd {
185191 if constexpr (std::is_same_v<xtd::wchar, char_t >) chars_ = str.chars_ ;
186192 else chars_ = __xtd_convert_to_string<value_type>(str.chars_ );
187193 }
188-
189- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index.
190- // / @param str The string to copy.
191- // / @param index The index of the first substring character where start copy.
192- // / @exception xtd::argument_out_of_range_exception `index` is greater or equal than `str` size.
193- basic_string (const basic_string<char >& str, xtd::size index) {
194- if (index > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
195- if constexpr (std::is_same_v<char , char_t >) chars_ = base_type (str.chars_ , index);
196- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<char >(str.chars_ , index)));
197- }
198- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index.
199- // / @param str The string to copy.
200- // / @param index The index of the first substring character where start copy.
201- // / @exception xtd::argument_out_of_range_exception `index` is greater or equal than `str` size.
202- basic_string (const basic_string<xtd::char16>& str, xtd::size index) {
203- if (index > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
204- if constexpr (std::is_same_v<xtd::char16, char_t >) chars_ = base_type (str.chars_ , index);
205- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_ , index)));
206- }
207- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index.
208- // / @param str The string to copy.
209- // / @param index The index of the first substring character where start copy.
210- // / @exception xtd::argument_out_of_range_exception `index` is greater or equal than `str` size.
211- basic_string (const basic_string<xtd::char32>& str, xtd::size index) {
212- if (index > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
213- if constexpr (std::is_same_v<xtd::char32, char_t >) chars_ = base_type (str.chars_ , index);
214- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_ , index)));
215- }
216- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index.
217- // / @param str The string to copy.
218- // / @param index The index of the first substring character where start copy.
219- // / @exception xtd::argument_out_of_range_exception `index` is greater or equal than `str` size.
220- basic_string (const basic_string<xtd::char8>& str, xtd::size index) {
221- if (index > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
222- if constexpr (std::is_same_v<xtd::char8, char_t >) chars_ = base_type (str.chars_ , index);
223- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_ , index)));
224- }
225- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index.
226- // / @param str The string to copy.
227- // / @param index The index of the first substring character where start copy.
228- // / @exception xtd::argument_out_of_range_exception `index` is greater or equal than `str` size.
229- basic_string (const basic_string<xtd::wchar>& str, xtd::size index) {
230- if (index > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
231- if constexpr (std::is_same_v<xtd::wchar, char_t >) chars_ = base_type (str.chars_ , index);
232- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_ , index)));
233- }
234- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index and count characters.
194+ // / @brief Initializes a new instance of xtd::basic_string with specified string to copy.
235195 // / @param str The string to copy.
236- // / @param index The index of the first substring character where start copy.
237- // / @param count The number of substring characters to copy.
238- // / @exception xtd::argument_out_of_range_exception `index` + `count`is greater or equal than `str` size.
239- basic_string (const basic_string<char >& str, xtd::size index, xtd::size count) {
240- if (index + count > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
241- if constexpr (std::is_same_v<char , char_t >) chars_ = base_type (str.chars_ , index, count);
242- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<char >(str.chars_ , index, count)));
196+ basic_string (const std::basic_string<char >& str) noexcept { // Can't be explicit by design.
197+ if constexpr (std::is_same_v<char , char_t >) chars_ = str;
198+ else chars_ = __xtd_convert_to_string<value_type>(str);
243199 }
244- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index and count characters .
200+ // / @brief Initializes a new instance of xtd::basic_string with specified string to copy .
245201 // / @param str The string to copy.
246- // / @param index The index of the first substring character where start copy.
247- // / @param count The number of substring characters to copy.
248- // / @exception xtd::argument_out_of_range_exception `index` + `count`is greater or equal than `str` size.
249- basic_string (const basic_string<xtd::char16>& str, xtd::size index, xtd::size count) {
250- if (index + count > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
251- if constexpr (std::is_same_v<xtd::char16, char_t >) chars_ = base_type (str.chars_ , index, count);
252- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_ , index, count)));
202+ basic_string (const std::basic_string<xtd::char16>& str) noexcept { // Can't be explicit by design.
203+ if constexpr (std::is_same_v<xtd::char16, char_t >) chars_ = str;
204+ else chars_ = __xtd_convert_to_string<value_type>(str);
253205 }
254- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index and count characters .
206+ // / @brief Initializes a new instance of xtd::basic_string with specified string to copy .
255207 // / @param str The string to copy.
256- // / @param index The index of the first substring character where start copy.
257- // / @param count The number of substring characters to copy.
258- // / @exception xtd::argument_out_of_range_exception `index` + `count`is greater or equal than `str` size.
259- basic_string (const basic_string<xtd::char32>& str, xtd::size index, xtd::size count) {
260- if (index + count > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
261- if constexpr (std::is_same_v<xtd::char32, char_t >) chars_ = base_type (str.chars_ , index, count);
262- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_ , index, count)));
208+ basic_string (const std::basic_string<xtd::char32>& str) noexcept { // Can't be explicit by design.
209+ if constexpr (std::is_same_v<xtd::char32, char_t >) chars_ = str;
210+ else chars_ = __xtd_convert_to_string<value_type>(str);
263211 }
264- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index and count characters .
212+ // / @brief Initializes a new instance of xtd::basic_string with specified string to copy .
265213 // / @param str The string to copy.
266- // / @param index The index of the first substring character where start copy.
267- // / @param count The number of substring characters to copy.
268- // / @exception xtd::argument_out_of_range_exception `index` + `count`is greater or equal than `str` size.
269- basic_string (const basic_string<xtd::char8>& str, xtd::size index, xtd::size count) {
270- if (index + count > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
271- if constexpr (std::is_same_v<xtd::char8, char_t >) chars_ = base_type (str.chars_ , index, count);
272- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_ , index, count)));
214+ basic_string (const std::basic_string<xtd::char8>& str) noexcept { // Can't be explicit by design.
215+ if constexpr (std::is_same_v<xtd::char8, char_t >) chars_ = str;
216+ else chars_ = __xtd_convert_to_string<value_type>(str);
273217 }
274- // / @brief Initializes a new instance of xtd::basic_string with specified substring at index and count characters .
218+ // / @brief Initializes a new instance of xtd::basic_string with specified string to copy .
275219 // / @param str The string to copy.
276- // / @param index The index of the first substring character where start copy.
277- // / @param count The number of substring characters to copy.
278- // / @exception xtd::argument_out_of_range_exception `index` + `count`is greater or equal than `str` size.
279- basic_string (const basic_string<xtd::wchar>& str, xtd::size index, xtd::size count) {
280- if (index + count > str.length ()) xtd::helpers::throw_helper::throws (xtd::helpers::exception_case::argument_out_of_range);
281- if constexpr (std::is_same_v<xtd::wchar, char_t >) chars_ = base_type (str.chars_ , index, count);
282- else chars_ = base_type (__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_ , index, count)));
220+ basic_string (const std::basic_string<xtd::wchar>& str) noexcept { // Can't be explicit by design.
221+ if constexpr (std::is_same_v<xtd::wchar, char_t >) chars_ = str;
222+ else chars_ = __xtd_convert_to_string<value_type>(str);
283223 }
284-
285- // / @brief Initializes a new instance of xtd::basic_string with specified string to move.
286- // / @param str The basic_string to move.
287- basic_string (basic_string&&) = default ;
288-
289224 // / @brief Initializes a new instance of xtd::basic_string with specified count copies of character.
290225 // / @param character The character copied.
291226 // / @param count The number of copies of character.
@@ -306,7 +241,6 @@ namespace xtd {
306241 // / @param character The character copied.
307242 // / @param count The number of copies of character.
308243 basic_string (xtd::wchar character, xtd::size count) : basic_string(std::basic_string<xtd::wchar>(count, character)) {}
309-
310244 // / @brief Initializes a new instance of xtd::basic_string with specified string to copy.
311245 // / @param str The string to copy.
312246 basic_string (const char * str) { // Can't be explicit by design.
@@ -378,57 +312,14 @@ namespace xtd {
378312 if constexpr (std::is_same_v<xtd::wchar, char_t >) chars_ = std::basic_string<xtd::wchar>(str, count);
379313 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count));
380314 }
381-
382- // / @brief Initializes a new instance of xtd::basic_string with specified string to copy.
383- // / @param str The string to copy.
384- basic_string (const std::basic_string<char >& str) noexcept { // Can't be explicit by design.
385- if constexpr (std::is_same_v<char , char_t >) chars_ = str;
386- else chars_ = __xtd_convert_to_string<value_type>(str);
387- }
388- // / @brief Initializes a new instance of xtd::basic_string with specified string to copy.
389- // / @param str The string to copy.
390- basic_string (const std::basic_string<xtd::char16>& str) noexcept { // Can't be explicit by design.
391- if constexpr (std::is_same_v<xtd::char16, char_t >) chars_ = str;
392- else chars_ = __xtd_convert_to_string<value_type>(str);
393- }
394- // / @brief Initializes a new instance of xtd::basic_string with specified string to copy.
395- // / @param str The string to copy.
396- basic_string (const std::basic_string<xtd::char32>& str) noexcept { // Can't be explicit by design.
397- if constexpr (std::is_same_v<xtd::char32, char_t >) chars_ = str;
398- else chars_ = __xtd_convert_to_string<value_type>(str);
399- }
400- // / @brief Initializes a new instance of xtd::basic_string with specified string to copy.
401- // / @param str The string to copy.
402- basic_string (const std::basic_string<xtd::char8>& str) noexcept { // Can't be explicit by design.
403- if constexpr (std::is_same_v<xtd::char8, char_t >) chars_ = str;
404- else chars_ = __xtd_convert_to_string<value_type>(str);
405- }
406- // / @brief Initializes a new instance of xtd::basic_string with specified string to copy.
407- // / @param str The string to copy.
408- basic_string (const std::basic_string<xtd::wchar>& str) noexcept { // Can't be explicit by design.
409- if constexpr (std::is_same_v<xtd::wchar, char_t >) chars_ = str;
410- else chars_ = __xtd_convert_to_string<value_type>(str);
411- }
412-
413315 // / @brief Initializes a new instance of xtd::basic_string with specified first and last iterators of substring.
414316 // / @param first The first iterator of substring.
415317 // / @param last The first iterator of substring.
416318 template <class input_iterator_t >
417319 basic_string (input_iterator_t first, input_iterator_t last) : chars_(first, last) {}
418-
419- // / @brief Initializes a new instance of xtd::basic_string with specified string view of substring and allocator.
420- // / @param string_view The basic_string view.
421- // / @param allocator The allocator to use for all memory allocations of this basic_string.
422- template <class string_view_like_t >
423- explicit constexpr basic_string (const string_view_like_t & string_view) : chars_(string_view) {}
424- // / @brief Initializes a new instance of xtd::basic_string with specified string view of substring and allocator.
425- // / @param string_view The basic_string view.
426- // / @param index The index of the first substring character where start copy.
427- // / @param count The number of substring characters to copy.
428- // / @param allocator The allocator to use for all memory allocations of this basic_string.
429- template <class string_view_like_t >
430- constexpr basic_string (const string_view_like_t & string_view, size_type index, size_type count) : chars_(string_view, index, count) {}
431-
320+ // / @brief Initializes a new instance of xtd::basic_string with specified std::basic_string_view.
321+ // / @param str The std::basic_string_view string.
322+ basic_string (const std::basic_string_view<char_t >& str) : chars_(str) {}
432323 // / @brief Initializes a new instance of xtd::basic_string with specified initializer list.
433324 // / @param il The initializer list to fill.
434325 basic_string (std::initializer_list<char > il) : basic_string(std::basic_string<char >(il)) {}
@@ -458,10 +349,10 @@ namespace xtd {
458349 // / @remarks Writing to the character array accessed through c_str() is undefined behavior.
459350 // / @remarks c_str() and data() perform the same function.
460351 const_pointer c_str () const noexcept {return chars_.c_str ();}
352+
461353 // / @brief Returns a reference to the underlying base type.
462354 // / @return Reference to the underlying base type.
463355 const base_type& chars () const noexcept {return chars_;}
464-
465356 // / @brief Returns a reference to the underlying base type.
466357 // / @return Reference to the underlying base type.
467358 base_type& chars () noexcept {return chars_;}
0 commit comments