/**
* @brief Default constructor creates an empty string.
*/
- basic_string()
-#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
- : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
-#else
- : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
-#endif
- { }
+ inline
+ basic_string();
/**
* @brief Construct an empty string using allocator @a a.
* max_size(), length_error is thrown. The value of the string doesn't
* change if an error is thrown.
*/
- basic_string&
- replace(iterator __i1, iterator __i2, initializer_list<_CharT> __l)
+ basic_string& replace(iterator __i1, iterator __i2,
+ initializer_list<_CharT> __l)
{ return this->replace(__i1, __i2, __l.begin(), __l.end()); }
#endif // __GXX_EXPERIMENTAL_CXX0X__
static _CharT*
_S_construct_aux(_Integer __beg, _Integer __end,
const _Alloc& __a, __true_type)
- { return _S_construct(static_cast<size_type>(__beg), __end, __a); }
+ { return _S_construct(static_cast<size_type>(__beg),
+ static_cast<value_type>(__end), __a); }
template<class _InIterator>
static _CharT*
return _S_construct_aux(__beg, __end, __a, _Integral());
}
- static _CharT*
- _S_construct(_CharT* __beg, _CharT* __end, const _Alloc& __a)
- {
- __glibcxx_requires_valid_range(__beg, __end);
- return _S_construct(__beg, __end - __beg, __a);
- }
-
- static _CharT*
- _S_construct(const _CharT* __beg, const _CharT* __end, const _Alloc& __a)
- {
- __glibcxx_requires_valid_range(__beg, __end);
- return _S_construct(__beg, __end - __beg, __a);
- }
-
- static _CharT*
- _S_construct(iterator __beg, iterator __end, const _Alloc& __a)
- {
- __glibcxx_requires_valid_range(__beg, __end);
- return _S_construct(__beg.base(), __end - __beg, __a);
- }
-
- static _CharT*
- _S_construct(const_iterator __beg, const_iterator __end,
- const _Alloc& __a)
- {
- __glibcxx_requires_valid_range(__beg, __end);
- return _S_construct(__beg.base(), __end - __beg, __a);
- }
-
// For Input Iterators, used in istreambuf_iterators, etc.
template<class _InIterator>
static _CharT*
static _CharT*
_S_construct(size_type __req, _CharT __c, const _Alloc& __a);
- static _CharT*
- _S_construct(const _CharT* __s, size_type __n, const _Alloc& __a);
-
public:
/**
size_type __n2) const;
};
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ inline basic_string<_CharT, _Traits, _Alloc>::
+ basic_string()
+#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
+ : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
+#else
+ : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()) { }
+#endif
+
// operator+
/**
* @brief Concatenate two strings.
{ return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
// NB: (v)snprintf vs sprintf.
+
+ // DR 1261.
+ inline string
+ to_string(int __val)
+ { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(int),
+ "%d", __val); }
+
+ inline string
+ to_string(unsigned __val)
+ { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
+ 4 * sizeof(unsigned),
+ "%u", __val); }
+
+ inline string
+ to_string(long __val)
+ { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(long),
+ "%ld", __val); }
+
+ inline string
+ to_string(unsigned long __val)
+ { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
+ 4 * sizeof(unsigned long),
+ "%lu", __val); }
+
inline string
to_string(long long __val)
{ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
"%llu", __val); }
inline string
+ to_string(float __val)
+ {
+ const int __n =
+ __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
+ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
+ "%f", __val);
+ }
+
+ inline string
+ to_string(double __val)
+ {
+ const int __n =
+ __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
+ return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
+ "%f", __val);
+ }
+
+ inline string
to_string(long double __val)
{
const int __n =
stold(const wstring& __str, size_t* __idx = 0)
{ return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); }
+ // DR 1261.
+ inline wstring
+ to_wstring(int __val)
+ { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(int),
+ L"%d", __val); }
+
+ inline wstring
+ to_wstring(unsigned __val)
+ { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
+ 4 * sizeof(unsigned),
+ L"%u", __val); }
+
+ inline wstring
+ to_wstring(long __val)
+ { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 * sizeof(long),
+ L"%ld", __val); }
+
+ inline wstring
+ to_wstring(unsigned long __val)
+ { return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
+ 4 * sizeof(unsigned long),
+ L"%lu", __val); }
+
inline wstring
to_wstring(long long __val)
{ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
L"%llu", __val); }
inline wstring
+ to_wstring(float __val)
+ {
+ const int __n =
+ __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
+ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
+ L"%f", __val);
+ }
+
+ inline wstring
+ to_wstring(double __val)
+ {
+ const int __n =
+ __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
+ return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
+ L"%f", __val);
+ }
+
+ inline wstring
to_wstring(long double __val)
{
const int __n =