29 #ifndef _STRING_CONVERSIONS_H 30 #define _STRING_CONVERSIONS_H 1 32 #pragma GCC system_header 34 #if __cplusplus < 201103L 46 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
51 template<
typename _TRet,
typename _Ret = _TRet,
typename _CharT,
54 __stoa(_TRet (*__convf) (
const _CharT*, _CharT**, _Base...),
55 const char* __name,
const _CharT* __str, std::size_t* __idx,
63 _Save_errno() : _M_errno(errno) { errno = 0; }
64 ~_Save_errno() {
if (errno == 0) errno = _M_errno; }
68 const _TRet __tmp = __convf(__str, &__endptr, __base...);
70 if (__endptr == __str)
71 std::__throw_invalid_argument(__name);
72 else if (errno == ERANGE
73 || (std::__are_same<_Ret, int>::__value
74 && (__tmp < __numeric_traits<int>::__min
75 || __tmp > __numeric_traits<int>::__max)))
76 std::__throw_out_of_range(__name);
81 *__idx = __endptr - __str;
87 template<
typename _String,
typename _CharT =
typename _String::value_type>
89 __to_xstring(
int (*__convf) (_CharT*, std::size_t,
const _CharT*,
90 __builtin_va_list), std::size_t __n,
91 const _CharT* __fmt, ...)
95 _CharT* __s =
static_cast<_CharT*
>(__builtin_alloca(
sizeof(_CharT)
98 __builtin_va_list __args;
99 __builtin_va_start(__args, __fmt);
101 const int __len = __convf(__s, __n, __fmt, __args);
103 __builtin_va_end(__args);
105 return _String(__s, __s + __len);
108 _GLIBCXX_END_NAMESPACE_VERSION
113 #endif // _STRING_CONVERSIONS_H
GNU extensions for public use.