now works with -fno-exceptions and -fno-rtti

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@110828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-08-11 17:04:31 +00:00
parent 81e68580b2
commit d444470d6c
20 changed files with 394 additions and 10 deletions

View File

@@ -90,6 +90,10 @@
#define _LIBCPP_NO_EXCEPTIONS #define _LIBCPP_NO_EXCEPTIONS
#endif #endif
#if !(__has_feature(cxx_rtti))
#define _LIBCPP_NO_RTTI
#endif
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#define _LIBCPP_HAS_NO_STRONG_USING #define _LIBCPP_HAS_NO_STRONG_USING
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
@@ -139,6 +143,10 @@
#define _LIBCPP_NO_EXCEPTIONS #define _LIBCPP_NO_EXCEPTIONS
#endif #endif
#ifndef __GXX_RTTI
#define _LIBCPP_NO_RTTI
#endif
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifndef __GXX_EXPERIMENTAL_CXX0X__ #ifndef __GXX_EXPERIMENTAL_CXX0X__

View File

@@ -243,8 +243,10 @@ public:
virtual void destroy() = 0; virtual void destroy() = 0;
virtual void destroy_deallocate() = 0; virtual void destroy_deallocate() = 0;
virtual _R operator()() = 0; virtual _R operator()() = 0;
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const = 0; virtual const void* target(const type_info&) const = 0;
virtual const std::type_info& target_type() const = 0; virtual const std::type_info& target_type() const = 0;
#endif
}; };
template<class _R, class _A0> template<class _R, class _A0>
@@ -260,8 +262,10 @@ public:
virtual void destroy() = 0; virtual void destroy() = 0;
virtual void destroy_deallocate() = 0; virtual void destroy_deallocate() = 0;
virtual _R operator()(_A0) = 0; virtual _R operator()(_A0) = 0;
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const = 0; virtual const void* target(const type_info&) const = 0;
virtual const std::type_info& target_type() const = 0; virtual const std::type_info& target_type() const = 0;
#endif
}; };
template<class _R, class _A0, class _A1> template<class _R, class _A0, class _A1>
@@ -277,8 +281,10 @@ public:
virtual void destroy() = 0; virtual void destroy() = 0;
virtual void destroy_deallocate() = 0; virtual void destroy_deallocate() = 0;
virtual _R operator()(_A0, _A1) = 0; virtual _R operator()(_A0, _A1) = 0;
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const = 0; virtual const void* target(const type_info&) const = 0;
virtual const std::type_info& target_type() const = 0; virtual const std::type_info& target_type() const = 0;
#endif
}; };
template<class _R, class _A0, class _A1, class _A2> template<class _R, class _A0, class _A1, class _A2>
@@ -294,8 +300,10 @@ public:
virtual void destroy() = 0; virtual void destroy() = 0;
virtual void destroy_deallocate() = 0; virtual void destroy_deallocate() = 0;
virtual _R operator()(_A0, _A1, _A2) = 0; virtual _R operator()(_A0, _A1, _A2) = 0;
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const = 0; virtual const void* target(const type_info&) const = 0;
virtual const std::type_info& target_type() const = 0; virtual const std::type_info& target_type() const = 0;
#endif
}; };
template<class _FD, class _Alloc, class _FB> class __func; template<class _FD, class _Alloc, class _FB> class __func;
@@ -313,8 +321,10 @@ public:
virtual void destroy(); virtual void destroy();
virtual void destroy_deallocate(); virtual void destroy_deallocate();
virtual _R operator()(); virtual _R operator()();
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const; virtual const void* target(const type_info&) const;
virtual const std::type_info& target_type() const; virtual const std::type_info& target_type() const;
#endif
}; };
template<class _F, class _Alloc, class _R> template<class _F, class _Alloc, class _R>
@@ -360,6 +370,8 @@ __func<_F, _Alloc, _R()>::operator()()
return __invoke<_R>(__f_.first()); return __invoke<_R>(__f_.first());
} }
#ifndef _LIBCPP_NO_RTTI
template<class _F, class _Alloc, class _R> template<class _F, class _Alloc, class _R>
const void* const void*
__func<_F, _Alloc, _R()>::target(const type_info& __ti) const __func<_F, _Alloc, _R()>::target(const type_info& __ti) const
@@ -376,6 +388,8 @@ __func<_F, _Alloc, _R()>::target_type() const
return typeid(_F); return typeid(_F);
} }
#endif
template<class _F, class _Alloc, class _R, class _A0> template<class _F, class _Alloc, class _R, class _A0>
class __func<_F, _Alloc, _R(_A0)> class __func<_F, _Alloc, _R(_A0)>
: public __base<_R(_A0)> : public __base<_R(_A0)>
@@ -389,8 +403,10 @@ public:
virtual void destroy(); virtual void destroy();
virtual void destroy_deallocate(); virtual void destroy_deallocate();
virtual _R operator()(_A0); virtual _R operator()(_A0);
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const; virtual const void* target(const type_info&) const;
virtual const std::type_info& target_type() const; virtual const std::type_info& target_type() const;
#endif
}; };
template<class _F, class _Alloc, class _R, class _A0> template<class _F, class _Alloc, class _R, class _A0>
@@ -436,6 +452,8 @@ __func<_F, _Alloc, _R(_A0)>::operator()(_A0 __a0)
return __invoke(__f_.first(), __a0); return __invoke(__f_.first(), __a0);
} }
#ifndef _LIBCPP_NO_RTTI
template<class _F, class _Alloc, class _R, class _A0> template<class _F, class _Alloc, class _R, class _A0>
const void* const void*
__func<_F, _Alloc, _R(_A0)>::target(const type_info& __ti) const __func<_F, _Alloc, _R(_A0)>::target(const type_info& __ti) const
@@ -452,6 +470,8 @@ __func<_F, _Alloc, _R(_A0)>::target_type() const
return typeid(_F); return typeid(_F);
} }
#endif
template<class _F, class _Alloc, class _R, class _A0, class _A1> template<class _F, class _Alloc, class _R, class _A0, class _A1>
class __func<_F, _Alloc, _R(_A0, _A1)> class __func<_F, _Alloc, _R(_A0, _A1)>
: public __base<_R(_A0, _A1)> : public __base<_R(_A0, _A1)>
@@ -465,8 +485,10 @@ public:
virtual void destroy(); virtual void destroy();
virtual void destroy_deallocate(); virtual void destroy_deallocate();
virtual _R operator()(_A0, _A1); virtual _R operator()(_A0, _A1);
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const; virtual const void* target(const type_info&) const;
virtual const std::type_info& target_type() const; virtual const std::type_info& target_type() const;
#endif
}; };
template<class _F, class _Alloc, class _R, class _A0, class _A1> template<class _F, class _Alloc, class _R, class _A0, class _A1>
@@ -512,6 +534,8 @@ __func<_F, _Alloc, _R(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1)
return __invoke(__f_.first(), __a0, __a1); return __invoke(__f_.first(), __a0, __a1);
} }
#ifndef _LIBCPP_NO_RTTI
template<class _F, class _Alloc, class _R, class _A0, class _A1> template<class _F, class _Alloc, class _R, class _A0, class _A1>
const void* const void*
__func<_F, _Alloc, _R(_A0, _A1)>::target(const type_info& __ti) const __func<_F, _Alloc, _R(_A0, _A1)>::target(const type_info& __ti) const
@@ -528,6 +552,8 @@ __func<_F, _Alloc, _R(_A0, _A1)>::target_type() const
return typeid(_F); return typeid(_F);
} }
#endif
template<class _F, class _Alloc, class _R, class _A0, class _A1, class _A2> template<class _F, class _Alloc, class _R, class _A0, class _A1, class _A2>
class __func<_F, _Alloc, _R(_A0, _A1, _A2)> class __func<_F, _Alloc, _R(_A0, _A1, _A2)>
: public __base<_R(_A0, _A1, _A2)> : public __base<_R(_A0, _A1, _A2)>
@@ -541,8 +567,10 @@ public:
virtual void destroy(); virtual void destroy();
virtual void destroy_deallocate(); virtual void destroy_deallocate();
virtual _R operator()(_A0, _A1, _A2); virtual _R operator()(_A0, _A1, _A2);
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const; virtual const void* target(const type_info&) const;
virtual const std::type_info& target_type() const; virtual const std::type_info& target_type() const;
#endif
}; };
template<class _F, class _Alloc, class _R, class _A0, class _A1, class _A2> template<class _F, class _Alloc, class _R, class _A0, class _A1, class _A2>
@@ -588,6 +616,8 @@ __func<_F, _Alloc, _R(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2)
return __invoke(__f_.first(), __a0, __a1, __a2); return __invoke(__f_.first(), __a0, __a1, __a2);
} }
#ifndef _LIBCPP_NO_RTTI
template<class _F, class _Alloc, class _R, class _A0, class _A1, class _A2> template<class _F, class _Alloc, class _R, class _A0, class _A1, class _A2>
const void* const void*
__func<_F, _Alloc, _R(_A0, _A1, _A2)>::target(const type_info& __ti) const __func<_F, _Alloc, _R(_A0, _A1, _A2)>::target(const type_info& __ti) const
@@ -604,6 +634,8 @@ __func<_F, _Alloc, _R(_A0, _A1, _A2)>::target_type() const
return typeid(_F); return typeid(_F);
} }
#endif
} // __function } // __function
template<class _R> template<class _R>
@@ -669,10 +701,12 @@ public:
// 20.7.16.2.4, function invocation: // 20.7.16.2.4, function invocation:
_R operator()() const; _R operator()() const;
#ifndef _LIBCPP_NO_RTTI
// 20.7.16.2.5, function target access: // 20.7.16.2.5, function target access:
const std::type_info& target_type() const; const std::type_info& target_type() const;
template <typename _T> _T* target(); template <typename _T> _T* target();
template <typename _T> const _T* target() const; template <typename _T> const _T* target() const;
#endif
}; };
template<class _R> template<class _R>
@@ -797,11 +831,15 @@ template<class _R>
_R _R
function<_R()>::operator()() const function<_R()>::operator()() const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0) if (__f_ == 0)
throw bad_function_call(); throw bad_function_call();
#endif
return (*__f_)(); return (*__f_)();
} }
#ifndef _LIBCPP_NO_RTTI
template<class _R> template<class _R>
const std::type_info& const std::type_info&
function<_R()>::target_type() const function<_R()>::target_type() const
@@ -831,6 +869,8 @@ function<_R()>::target() const
return (const _T*)__f_->target(typeid(_T)); return (const _T*)__f_->target(typeid(_T));
} }
#endif
template<class _R, class _A0> template<class _R, class _A0>
class function<_R(_A0)> class function<_R(_A0)>
: public unary_function<_A0, _R> : public unary_function<_A0, _R>
@@ -905,10 +945,12 @@ public:
// 20.7.16.2.4, function invocation: // 20.7.16.2.4, function invocation:
_R operator()(_A0) const; _R operator()(_A0) const;
#ifndef _LIBCPP_NO_RTTI
// 20.7.16.2.5, function target access: // 20.7.16.2.5, function target access:
const std::type_info& target_type() const; const std::type_info& target_type() const;
template <typename _T> _T* target(); template <typename _T> _T* target();
template <typename _T> const _T* target() const; template <typename _T> const _T* target() const;
#endif
}; };
template<class _R, class _A0> template<class _R, class _A0>
@@ -1033,11 +1075,15 @@ template<class _R, class _A0>
_R _R
function<_R(_A0)>::operator()(_A0 __a0) const function<_R(_A0)>::operator()(_A0 __a0) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0) if (__f_ == 0)
throw bad_function_call(); throw bad_function_call();
#endif
return (*__f_)(__a0); return (*__f_)(__a0);
} }
#ifndef _LIBCPP_NO_RTTI
template<class _R, class _A0> template<class _R, class _A0>
const std::type_info& const std::type_info&
function<_R(_A0)>::target_type() const function<_R(_A0)>::target_type() const
@@ -1067,6 +1113,8 @@ function<_R(_A0)>::target() const
return (const _T*)__f_->target(typeid(_T)); return (const _T*)__f_->target(typeid(_T));
} }
#endif
template<class _R, class _A0, class _A1> template<class _R, class _A0, class _A1>
class function<_R(_A0, _A1)> class function<_R(_A0, _A1)>
: public binary_function<_A0, _A1, _R> : public binary_function<_A0, _A1, _R>
@@ -1141,10 +1189,12 @@ public:
// 20.7.16.2.4, function invocation: // 20.7.16.2.4, function invocation:
_R operator()(_A0, _A1) const; _R operator()(_A0, _A1) const;
#ifndef _LIBCPP_NO_RTTI
// 20.7.16.2.5, function target access: // 20.7.16.2.5, function target access:
const std::type_info& target_type() const; const std::type_info& target_type() const;
template <typename _T> _T* target(); template <typename _T> _T* target();
template <typename _T> const _T* target() const; template <typename _T> const _T* target() const;
#endif
}; };
template<class _R, class _A0, class _A1> template<class _R, class _A0, class _A1>
@@ -1269,11 +1319,15 @@ template<class _R, class _A0, class _A1>
_R _R
function<_R(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const function<_R(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0) if (__f_ == 0)
throw bad_function_call(); throw bad_function_call();
#endif
return (*__f_)(__a0, __a1); return (*__f_)(__a0, __a1);
} }
#ifndef _LIBCPP_NO_RTTI
template<class _R, class _A0, class _A1> template<class _R, class _A0, class _A1>
const std::type_info& const std::type_info&
function<_R(_A0, _A1)>::target_type() const function<_R(_A0, _A1)>::target_type() const
@@ -1303,6 +1357,8 @@ function<_R(_A0, _A1)>::target() const
return (const _T*)__f_->target(typeid(_T)); return (const _T*)__f_->target(typeid(_T));
} }
#endif
template<class _R, class _A0, class _A1, class _A2> template<class _R, class _A0, class _A1, class _A2>
class function<_R(_A0, _A1, _A2)> class function<_R(_A0, _A1, _A2)>
{ {
@@ -1376,10 +1432,12 @@ public:
// 20.7.16.2.4, function invocation: // 20.7.16.2.4, function invocation:
_R operator()(_A0, _A1, _A2) const; _R operator()(_A0, _A1, _A2) const;
#ifndef _LIBCPP_NO_RTTI
// 20.7.16.2.5, function target access: // 20.7.16.2.5, function target access:
const std::type_info& target_type() const; const std::type_info& target_type() const;
template <typename _T> _T* target(); template <typename _T> _T* target();
template <typename _T> const _T* target() const; template <typename _T> const _T* target() const;
#endif
}; };
template<class _R, class _A0, class _A1, class _A2> template<class _R, class _A0, class _A1, class _A2>
@@ -1504,11 +1562,15 @@ template<class _R, class _A0, class _A1, class _A2>
_R _R
function<_R(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const function<_R(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0) if (__f_ == 0)
throw bad_function_call(); throw bad_function_call();
#endif
return (*__f_)(__a0, __a1, __a2); return (*__f_)(__a0, __a1, __a2);
} }
#ifndef _LIBCPP_NO_RTTI
template<class _R, class _A0, class _A1, class _A2> template<class _R, class _A0, class _A1, class _A2>
const std::type_info& const std::type_info&
function<_R(_A0, _A1, _A2)>::target_type() const function<_R(_A0, _A1, _A2)>::target_type() const
@@ -1538,6 +1600,8 @@ function<_R(_A0, _A1, _A2)>::target() const
return (const _T*)__f_->target(typeid(_T)); return (const _T*)__f_->target(typeid(_T));
} }
#endif
template <class _F> template <class _F>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
bool bool

View File

@@ -134,8 +134,10 @@ template <class _Facet>
locale locale
locale::combine(const locale& __other) const locale::combine(const locale& __other) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!_STD::has_facet<_Facet>(__other)) if (!_STD::has_facet<_Facet>(__other))
throw runtime_error("locale::combine: locale missing facet"); throw runtime_error("locale::combine: locale missing facet");
#endif
return locale(*this, &const_cast<_Facet&>(_STD::use_facet<_Facet>(__other))); return locale(*this, &const_cast<_Facet&>(_STD::use_facet<_Facet>(__other)));
} }

View File

@@ -1102,8 +1102,10 @@ __tree<_Tp, _Compare, _Allocator>::__assign_unique(_InputIterator __first, _Inpu
if (size() != 0) if (size() != 0)
{ {
__node_pointer __cache = __detach(); __node_pointer __cache = __detach();
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
#endif
for (; __cache != nullptr && __first != __last; ++__first) for (; __cache != nullptr && __first != __last; ++__first)
{ {
__cache->__value_ = *__first; __cache->__value_ = *__first;
@@ -1111,6 +1113,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_unique(_InputIterator __first, _Inpu
__node_insert_unique(__cache); __node_insert_unique(__cache);
__cache = __next; __cache = __next;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) catch (...)
{ {
@@ -1119,6 +1122,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_unique(_InputIterator __first, _Inpu
destroy(__cache); destroy(__cache);
throw; throw;
} }
#endif
if (__cache != nullptr) if (__cache != nullptr)
{ {
while (__cache->__parent_ != nullptr) while (__cache->__parent_ != nullptr)
@@ -1138,8 +1142,10 @@ __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _Input
if (size() != 0) if (size() != 0)
{ {
__node_pointer __cache = __detach(); __node_pointer __cache = __detach();
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
#endif
for (; __cache != nullptr && __first != __last; ++__first) for (; __cache != nullptr && __first != __last; ++__first)
{ {
__cache->__value_ = *__first; __cache->__value_ = *__first;
@@ -1147,6 +1153,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _Input
__node_insert_multi(__cache); __node_insert_multi(__cache);
__cache = __next; __cache = __next;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) catch (...)
{ {
@@ -1155,6 +1162,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _Input
destroy(__cache); destroy(__cache);
throw; throw;
} }
#endif
if (__cache != nullptr) if (__cache != nullptr)
{ {
while (__cache->__parent_ != nullptr) while (__cache->__parent_ != nullptr)
@@ -1253,8 +1261,10 @@ __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type)
if (size() != 0) if (size() != 0)
{ {
__node_pointer __cache = __detach(); __node_pointer __cache = __detach();
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
#endif
while (__cache != nullptr && __t.size() != 0) while (__cache != nullptr && __t.size() != 0)
{ {
__cache->__value_ = _STD::move(__t.remove(__t.begin())->__value_); __cache->__value_ = _STD::move(__t.remove(__t.begin())->__value_);
@@ -1262,6 +1272,7 @@ __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type)
__node_insert_multi(__cache); __node_insert_multi(__cache);
__cache = __next; __cache = __next;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) catch (...)
{ {
@@ -1270,6 +1281,7 @@ __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type)
destroy(__cache); destroy(__cache);
throw; throw;
} }
#endif
if (__cache != nullptr) if (__cache != nullptr)
{ {
while (__cache->__parent_ != nullptr) while (__cache->__parent_ != nullptr)

View File

@@ -141,6 +141,7 @@ template<class _E>
exception_ptr exception_ptr
make_exception_ptr(_E __e) make_exception_ptr(_E __e)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
throw __e; throw __e;
@@ -149,6 +150,7 @@ make_exception_ptr(_E __e)
{ {
return current_exception(); return current_exception();
} }
#endif
} }
// nested_exception // nested_exception
@@ -188,7 +190,9 @@ throw_with_nested (_Tp& __t, typename enable_if<
>::type* = 0) >::type* = 0)
#endif #endif
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw __nested<typename remove_reference<_Tp>::type>(_STD::forward<_Tp>(__t)); throw __nested<typename remove_reference<_Tp>::type>(_STD::forward<_Tp>(__t));
#endif
} }
template <class _Tp> template <class _Tp>
@@ -204,7 +208,9 @@ throw_with_nested (_Tp& __t, typename enable_if<
>::type* = 0) >::type* = 0)
#endif #endif
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw _STD::forward<_Tp>(__t); throw _STD::forward<_Tp>(__t);
#endif
} }
template <class _E> template <class _E>

View File

@@ -1000,8 +1000,10 @@ public:
virtual void destroy() = 0; virtual void destroy() = 0;
virtual void destroy_deallocate() = 0; virtual void destroy_deallocate() = 0;
virtual _R operator()(_ArgTypes&& ...) = 0; virtual _R operator()(_ArgTypes&& ...) = 0;
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const = 0; virtual const void* target(const type_info&) const = 0;
virtual const std::type_info& target_type() const = 0; virtual const std::type_info& target_type() const = 0;
#endif
}; };
template<class _FD, class _Alloc, class _FB> class __func; template<class _FD, class _Alloc, class _FB> class __func;
@@ -1019,8 +1021,10 @@ public:
virtual void destroy(); virtual void destroy();
virtual void destroy_deallocate(); virtual void destroy_deallocate();
virtual _R operator()(_ArgTypes&& ... __arg); virtual _R operator()(_ArgTypes&& ... __arg);
#ifndef _LIBCPP_NO_RTTI
virtual const void* target(const type_info&) const; virtual const void* target(const type_info&) const;
virtual const std::type_info& target_type() const; virtual const std::type_info& target_type() const;
#endif
}; };
template<class _F, class _Alloc, class _R, class ..._ArgTypes> template<class _F, class _Alloc, class _R, class ..._ArgTypes>
@@ -1066,6 +1070,8 @@ __func<_F, _Alloc, _R(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg)
return __invoke(__f_.first(), _STD::forward<_ArgTypes>(__arg)...); return __invoke(__f_.first(), _STD::forward<_ArgTypes>(__arg)...);
} }
#ifndef _LIBCPP_NO_RTTI
template<class _F, class _Alloc, class _R, class ..._ArgTypes> template<class _F, class _Alloc, class _R, class ..._ArgTypes>
const void* const void*
__func<_F, _Alloc, _R(_ArgTypes...)>::target(const type_info& __ti) const __func<_F, _Alloc, _R(_ArgTypes...)>::target(const type_info& __ti) const
@@ -1082,6 +1088,8 @@ __func<_F, _Alloc, _R(_ArgTypes...)>::target_type() const
return typeid(_F); return typeid(_F);
} }
#endif
} // __function } // __function
template<class _R, class ..._ArgTypes> template<class _R, class ..._ArgTypes>
@@ -1163,10 +1171,12 @@ public:
// 20.7.16.2.4, function invocation: // 20.7.16.2.4, function invocation:
_R operator()(_ArgTypes...) const; _R operator()(_ArgTypes...) const;
#ifndef _LIBCPP_NO_RTTI
// 20.7.16.2.5, function target access: // 20.7.16.2.5, function target access:
const std::type_info& target_type() const; const std::type_info& target_type() const;
template <typename _T> _T* target(); template <typename _T> _T* target();
template <typename _T> const _T* target() const; template <typename _T> const _T* target() const;
#endif
}; };
template<class _R, class ..._ArgTypes> template<class _R, class ..._ArgTypes>
@@ -1331,11 +1341,15 @@ template<class _R, class ..._ArgTypes>
_R _R
function<_R(_ArgTypes...)>::operator()(_ArgTypes... __arg) const function<_R(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0) if (__f_ == 0)
throw bad_function_call(); throw bad_function_call();
#endif
return (*__f_)(_STD::forward<_ArgTypes>(__arg)...); return (*__f_)(_STD::forward<_ArgTypes>(__arg)...);
} }
#ifndef _LIBCPP_NO_RTTI
template<class _R, class ..._ArgTypes> template<class _R, class ..._ArgTypes>
const std::type_info& const std::type_info&
function<_R(_ArgTypes...)>::target_type() const function<_R(_ArgTypes...)>::target_type() const
@@ -1365,6 +1379,8 @@ function<_R(_ArgTypes...)>::target() const
return (const _T*)__f_->target(typeid(_T)); return (const _T*)__f_->target(typeid(_T));
} }
#endif
template <class _R, class... _ArgTypes> template <class _R, class... _ArgTypes>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
bool bool

View File

@@ -3690,8 +3690,10 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
if (__r == codecvt_base::ok) if (__r == codecvt_base::ok)
return __ws; return __ws;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__wide_err_string_.empty()) if (__wide_err_string_.empty())
throw range_error("wstring_convert: from_bytes error"); throw range_error("wstring_convert: from_bytes error");
#endif
return __wide_err_string_; return __wide_err_string_;
} }
@@ -3776,8 +3778,10 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::
return __bs; return __bs;
} }
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__byte_err_string_.empty()) if (__byte_err_string_.empty())
throw range_error("wstring_convert: to_bytes error"); throw range_error("wstring_convert: to_bytes error");
#endif
return __byte_err_string_; return __byte_err_string_;
} }

View File

@@ -1136,8 +1136,10 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
{ {
__node_base_pointer __parent; __node_base_pointer __parent;
__node_base_pointer& __child = __find_equal_key(__parent, __k); __node_base_pointer& __child = __find_equal_key(__parent, __k);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr) if (__child == nullptr)
throw out_of_range("map::at: key not found"); throw out_of_range("map::at: key not found");
#endif
return static_cast<__node_pointer>(__child)->__value_.second; return static_cast<__node_pointer>(__child)->__value_.second;
} }
@@ -1147,8 +1149,10 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
{ {
__node_base_const_pointer __parent; __node_base_const_pointer __parent;
__node_base_const_pointer __child = __find_equal_key(__parent, __k); __node_base_const_pointer __child = __find_equal_key(__parent, __k);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr) if (__child == nullptr)
throw out_of_range("map::at: key not found"); throw out_of_range("map::at: key not found");
#endif
return static_cast<__node_const_pointer>(__child)->__value_.second; return static_cast<__node_const_pointer>(__child)->__value_.second;
} }

View File

@@ -2642,7 +2642,9 @@ public:
long use_count() const {return __shared_count::use_count();} long use_count() const {return __shared_count::use_count();}
__shared_weak_count* lock(); __shared_weak_count* lock();
#ifndef _LIBCPP_NO_RTTI
virtual const void* __get_deleter(const type_info&) const; virtual const void* __get_deleter(const type_info&) const;
#endif
private: private:
virtual void __on_zero_shared_weak() = 0; virtual void __on_zero_shared_weak() = 0;
}; };
@@ -2656,13 +2658,17 @@ public:
__shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a)
: __data_(__compressed_pair<_Tp, _Dp>(__p, _STD::move(__d)), _STD::move(__a)) {} : __data_(__compressed_pair<_Tp, _Dp>(__p, _STD::move(__d)), _STD::move(__a)) {}
#ifndef _LIBCPP_NO_RTTI
virtual const void* __get_deleter(const type_info&) const; virtual const void* __get_deleter(const type_info&) const;
#endif
private: private:
virtual void __on_zero_shared(); virtual void __on_zero_shared();
virtual void __on_zero_shared_weak(); virtual void __on_zero_shared_weak();
}; };
#ifndef _LIBCPP_NO_RTTI
template <class _Tp, class _Dp, class _Alloc> template <class _Tp, class _Dp, class _Alloc>
const void* const void*
__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const
@@ -2670,6 +2676,8 @@ __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) cons
return __t == typeid(_Dp) ? &__data_.first().second() : 0; return __t == typeid(_Dp) ? &__data_.first().second() : 0;
} }
#endif
template <class _Tp, class _Dp, class _Alloc> template <class _Tp, class _Dp, class _Alloc>
void void
__shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared()
@@ -2834,9 +2842,11 @@ public:
template <class _U> bool owner_before(weak_ptr<_U> const& __p) const template <class _U> bool owner_before(weak_ptr<_U> const& __p) const
{return __cntrl_ < __p.__cntrl_;} {return __cntrl_ < __p.__cntrl_;}
#ifndef _LIBCPP_NO_RTTI
template <class _Dp> template <class _Dp>
_Dp* __get_deleter() const _Dp* __get_deleter() const
{return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);} {return (_Dp*)(__cntrl_ ? __cntrl_->__get_deleter(typeid(_Dp)) : 0);}
#endif
#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -3591,6 +3601,8 @@ const_pointer_cast(const shared_ptr<_Up>& __r)
return shared_ptr<_Tp>(__r, const_cast<_Tp*>(__r.get())); return shared_ptr<_Tp>(__r, const_cast<_Tp*>(__r.get()));
} }
#ifndef _LIBCPP_NO_RTTI
template<class _Dp, class _Tp> template<class _Dp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY
_Dp* _Dp*
@@ -3599,6 +3611,8 @@ get_deleter(const shared_ptr<_Tp>& __p)
return __p.template __get_deleter<_Dp>(); return __p.template __get_deleter<_Dp>();
} }
#endif
template<class _Tp> template<class _Tp>
class weak_ptr class weak_ptr
{ {

View File

@@ -2263,8 +2263,10 @@ public:
} }
else else
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__b.size() != 1 || __e.size() != 1) if (__b.size() != 1 || __e.size() != 1)
throw regex_error(regex_constants::error_collate); throw regex_error(regex_constants::error_collate);
#endif
if (__icase_) if (__icase_)
{ {
__b[0] = __traits_.translate_nocase(__b[0]); __b[0] = __traits_.translate_nocase(__b[0]);
@@ -2894,8 +2896,10 @@ basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
case egrep: case egrep:
__first = __parse_egrep(__first, __last); __first = __parse_egrep(__first, __last);
break; break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default: default:
throw regex_error(regex_constants::__re_err_grammar); throw regex_error(regex_constants::__re_err_grammar);
#endif
} }
return __first; return __first;
} }
@@ -2926,8 +2930,10 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first,
} }
} }
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first != __last) if (__first != __last)
throw regex_error(regex_constants::__re_err_empty); throw regex_error(regex_constants::__re_err_empty);
#endif
} }
return __first; return __first;
} }
@@ -2940,15 +2946,19 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
{ {
__owns_one_state<_CharT>* __sa = __end_; __owns_one_state<_CharT>* __sa = __end_;
_ForwardIterator __temp = __parse_ERE_branch(__first, __last); _ForwardIterator __temp = __parse_ERE_branch(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::__re_err_empty); throw regex_error(regex_constants::__re_err_empty);
#endif
__first = __temp; __first = __temp;
while (__first != __last && *__first == '|') while (__first != __last && *__first == '|')
{ {
__owns_one_state<_CharT>* __sb = __end_; __owns_one_state<_CharT>* __sb = __end_;
__temp = __parse_ERE_branch(++__first, __last); __temp = __parse_ERE_branch(++__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::__re_err_empty); throw regex_error(regex_constants::__re_err_empty);
#endif
__push_alternation(__sa, __sb); __push_alternation(__sa, __sb);
__first = __temp; __first = __temp;
} }
@@ -2962,8 +2972,10 @@ basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first,
_ForwardIterator __last) _ForwardIterator __last)
{ {
_ForwardIterator __temp = __parse_ERE_expression(__first, __last); _ForwardIterator __temp = __parse_ERE_expression(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::__re_err_empty); throw regex_error(regex_constants::__re_err_empty);
#endif
do do
{ {
__first = __temp; __first = __temp;
@@ -2998,8 +3010,10 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first,
unsigned __temp_count = __marked_count_; unsigned __temp_count = __marked_count_;
++__open_count_; ++__open_count_;
__temp = __parse_extended_reg_exp(++__temp, __last); __temp = __parse_extended_reg_exp(++__temp, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last || *__temp != ')') if (__temp == __last || *__temp != ')')
throw regex_error(regex_constants::error_paren); throw regex_error(regex_constants::error_paren);
#endif
__push_end_marked_subexpression(__temp_count); __push_end_marked_subexpression(__temp_count);
--__open_count_; --__open_count_;
++__temp; ++__temp;
@@ -3064,8 +3078,10 @@ basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first,
unsigned __temp_count = __marked_count_; unsigned __temp_count = __marked_count_;
__first = __parse_RE_expression(__temp, __last); __first = __parse_RE_expression(__temp, __last);
__temp = __parse_Back_close_paren(__first, __last); __temp = __parse_Back_close_paren(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_paren); throw regex_error(regex_constants::error_paren);
#endif
__push_end_marked_subexpression(__temp_count); __push_end_marked_subexpression(__temp_count);
__first = __temp; __first = __temp;
} }
@@ -3374,16 +3390,22 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
int __min = 0; int __min = 0;
__first = __temp; __first = __temp;
__temp = __parse_DUP_COUNT(__first, __last, __min); __temp = __parse_DUP_COUNT(__first, __last, __min);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_badbrace); throw regex_error(regex_constants::error_badbrace);
#endif
__first = __temp; __first = __temp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_brace); throw regex_error(regex_constants::error_brace);
#endif
if (*__first != ',') if (*__first != ',')
{ {
__temp = __parse_Back_close_brace(__first, __last); __temp = __parse_Back_close_brace(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_brace); throw regex_error(regex_constants::error_brace);
#endif
__push_loop(__min, __min, __s, __mexp_begin, __mexp_end, __push_loop(__min, __min, __s, __mexp_begin, __mexp_end,
true); true);
__first = __temp; __first = __temp;
@@ -3394,14 +3416,18 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first,
int __max = -1; int __max = -1;
__first = __parse_DUP_COUNT(__first, __last, __max); __first = __parse_DUP_COUNT(__first, __last, __max);
__temp = __parse_Back_close_brace(__first, __last); __temp = __parse_Back_close_brace(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_brace); throw regex_error(regex_constants::error_brace);
#endif
if (__max == -1) if (__max == -1)
__push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
else else
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__max < __min) if (__max < __min)
throw regex_error(regex_constants::error_badbrace); throw regex_error(regex_constants::error_badbrace);
#endif
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end, __push_loop(__min, __max, __s, __mexp_begin, __mexp_end,
true); true);
} }
@@ -3461,11 +3487,15 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
{ {
int __min; int __min;
_ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min); _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_badbrace); throw regex_error(regex_constants::error_badbrace);
#endif
__first = __temp; __first = __temp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_brace); throw regex_error(regex_constants::error_brace);
#endif
switch (*__first) switch (*__first)
{ {
case '}': case '}':
@@ -3479,8 +3509,11 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
__push_loop(__min, __min, __s, __mexp_begin, __mexp_end); __push_loop(__min, __min, __s, __mexp_begin, __mexp_end);
break; break;
case ',': case ',':
if (++__first == __last) ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_badbrace); throw regex_error(regex_constants::error_badbrace);
#endif
if (*__first == '}') if (*__first == '}')
{ {
++__first; ++__first;
@@ -3496,14 +3529,20 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
{ {
int __max = -1; int __max = -1;
__temp = __parse_DUP_COUNT(__first, __last, __max); __temp = __parse_DUP_COUNT(__first, __last, __max);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __first) if (__temp == __first)
throw regex_error(regex_constants::error_brace); throw regex_error(regex_constants::error_brace);
#endif
__first = __temp; __first = __temp;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != '}') if (__first == __last || *__first != '}')
throw regex_error(regex_constants::error_brace); throw regex_error(regex_constants::error_brace);
#endif
++__first; ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__max < __min) if (__max < __min)
throw regex_error(regex_constants::error_badbrace); throw regex_error(regex_constants::error_badbrace);
#endif
if (__grammar == ECMAScript && __first != __last && *__first == '?') if (__grammar == ECMAScript && __first != __last && *__first == '?')
{ {
++__first; ++__first;
@@ -3513,8 +3552,10 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first,
__push_loop(__min, __max, __s, __mexp_begin, __mexp_end); __push_loop(__min, __max, __s, __mexp_begin, __mexp_end);
} }
break; break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default: default:
throw regex_error(regex_constants::error_badbrace); throw regex_error(regex_constants::error_badbrace);
#endif
} }
} }
break; break;
@@ -3531,8 +3572,11 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
{ {
if (__first != __last && *__first == '[') if (__first != __last && *__first == '[')
{ {
if (++__first == __last) ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_brack); throw regex_error(regex_constants::error_brack);
#endif
bool __negate = false; bool __negate = false;
if (*__first == '^') if (*__first == '^')
{ {
@@ -3541,23 +3585,29 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
} }
__bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate); __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
// __ml owned by *this // __ml owned by *this
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_brack); throw regex_error(regex_constants::error_brack);
#endif
if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']') if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']')
{ {
__ml->__add_char(']'); __ml->__add_char(']');
++__first; ++__first;
} }
__first = __parse_follow_list(__first, __last, __ml); __first = __parse_follow_list(__first, __last, __ml);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_brack); throw regex_error(regex_constants::error_brack);
#endif
if (*__first == '-') if (*__first == '-')
{ {
__ml->__add_char('-'); __ml->__add_char('-');
++__first; ++__first;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != ']') if (__first == __last || *__first != ']')
throw regex_error(regex_constants::error_brack); throw regex_error(regex_constants::error_brack);
#endif
++__first; ++__first;
} }
return __first; return __first;
@@ -3677,8 +3727,10 @@ basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first,
basic_string<_CharT>& __str, basic_string<_CharT>& __str,
__bracket_expression<_CharT, _Traits>* __ml) __bracket_expression<_CharT, _Traits>* __ml)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
switch (*__first) switch (*__first)
{ {
case 0: case 0:
@@ -3719,8 +3771,10 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
_ForwardIterator __last, _ForwardIterator __last,
basic_string<_CharT>* __str) basic_string<_CharT>* __str)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last) if (__first == __last)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
switch (*__first) switch (*__first)
{ {
case '\\': case '\\':
@@ -3788,8 +3842,10 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first,
else else
__push_char(_CharT(__val)); __push_char(_CharT(__val));
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
else else
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
return __first; return __first;
} }
@@ -3805,14 +3861,18 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first
value_type _Equal_close[2] = {'=', ']'}; value_type _Equal_close[2] = {'=', ']'};
_ForwardIterator __temp = _STD::search(__first, __last, _Equal_close, _ForwardIterator __temp = _STD::search(__first, __last, _Equal_close,
_Equal_close+2); _Equal_close+2);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last) if (__temp == __last)
throw regex_error(regex_constants::error_brack); throw regex_error(regex_constants::error_brack);
#endif
// [__first, __temp) contains all text in [= ... =] // [__first, __temp) contains all text in [= ... =]
typedef typename _Traits::string_type string_type; typedef typename _Traits::string_type string_type;
string_type __collate_name = string_type __collate_name =
__traits_.lookup_collatename(__first, __temp); __traits_.lookup_collatename(__first, __temp);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__collate_name.empty()) if (__collate_name.empty())
throw regex_error(regex_constants::error_collate); throw regex_error(regex_constants::error_collate);
#endif
string_type __equiv_name = string_type __equiv_name =
__traits_.transform_primary(__collate_name.begin(), __traits_.transform_primary(__collate_name.begin(),
__collate_name.end()); __collate_name.end());
@@ -3828,8 +3888,10 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first
case 2: case 2:
__ml->__add_digraph(__collate_name[0], __collate_name[1]); __ml->__add_digraph(__collate_name[0], __collate_name[1]);
break; break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default: default:
throw regex_error(regex_constants::error_collate); throw regex_error(regex_constants::error_collate);
#endif
} }
} }
__first = next(__temp, 2); __first = next(__temp, 2);
@@ -3848,14 +3910,18 @@ basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first,
value_type _Colon_close[2] = {':', ']'}; value_type _Colon_close[2] = {':', ']'};
_ForwardIterator __temp = _STD::search(__first, __last, _Colon_close, _ForwardIterator __temp = _STD::search(__first, __last, _Colon_close,
_Colon_close+2); _Colon_close+2);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last) if (__temp == __last)
throw regex_error(regex_constants::error_brack); throw regex_error(regex_constants::error_brack);
#endif
// [__first, __temp) contains all text in [: ... :] // [__first, __temp) contains all text in [: ... :]
typedef typename _Traits::char_class_type char_class_type; typedef typename _Traits::char_class_type char_class_type;
char_class_type __class_type = char_class_type __class_type =
__traits_.lookup_classname(__first, __temp, __flags_ & icase); __traits_.lookup_classname(__first, __temp, __flags_ & icase);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__class_type == 0) if (__class_type == 0)
throw regex_error(regex_constants::error_brack); throw regex_error(regex_constants::error_brack);
#endif
__ml->__add_class(__class_type); __ml->__add_class(__class_type);
__first = next(__temp, 2); __first = next(__temp, 2);
return __first; return __first;
@@ -3873,8 +3939,10 @@ basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
value_type _Dot_close[2] = {'.', ']'}; value_type _Dot_close[2] = {'.', ']'};
_ForwardIterator __temp = _STD::search(__first, __last, _Dot_close, _ForwardIterator __temp = _STD::search(__first, __last, _Dot_close,
_Dot_close+2); _Dot_close+2);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last) if (__temp == __last)
throw regex_error(regex_constants::error_brack); throw regex_error(regex_constants::error_brack);
#endif
// [__first, __temp) contains all text in [. ... .] // [__first, __temp) contains all text in [. ... .]
typedef typename _Traits::string_type string_type; typedef typename _Traits::string_type string_type;
__col_sym = __traits_.lookup_collatename(__first, __temp); __col_sym = __traits_.lookup_collatename(__first, __temp);
@@ -3883,8 +3951,10 @@ basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first,
case 1: case 1:
case 2: case 2:
break; break;
#ifndef _LIBCPP_NO_EXCEPTIONS
default: default:
throw regex_error(regex_constants::error_collate); throw regex_error(regex_constants::error_collate);
#endif
} }
__first = next(__temp, 2); __first = next(__temp, 2);
return __first; return __first;
@@ -4022,8 +4092,10 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
__temp = __exp.__parse(++__temp, __last); __temp = __exp.__parse(++__temp, __last);
__exp.__push_l_anchor(); __exp.__push_l_anchor();
__push_lookahead(_STD::move(__exp), false); __push_lookahead(_STD::move(__exp), false);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last || *__temp != ')') if (__temp == __last || *__temp != ')')
throw regex_error(regex_constants::error_paren); throw regex_error(regex_constants::error_paren);
#endif
__first = ++__temp; __first = ++__temp;
} }
break; break;
@@ -4034,8 +4106,10 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first,
__temp = __exp.__parse(++__temp, __last); __temp = __exp.__parse(++__temp, __last);
__exp.__push_l_anchor(); __exp.__push_l_anchor();
__push_lookahead(_STD::move(__exp), true); __push_lookahead(_STD::move(__exp), true);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__temp == __last || *__temp != ')') if (__temp == __last || *__temp != ')')
throw regex_error(regex_constants::error_paren); throw regex_error(regex_constants::error_paren);
#endif
__first = ++__temp; __first = ++__temp;
} }
break; break;
@@ -4071,15 +4145,20 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
break; break;
case '(': case '(':
{ {
if (++__first == __last) ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_paren); throw regex_error(regex_constants::error_paren);
#endif
_ForwardIterator __temp = _STD::next(__first); _ForwardIterator __temp = _STD::next(__first);
if (__temp != __last && *__first == '?' && *__temp == ':') if (__temp != __last && *__first == '?' && *__temp == ':')
{ {
++__open_count_; ++__open_count_;
__first = __parse_ecma_exp(++__temp, __last); __first = __parse_ecma_exp(++__temp, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != ')') if (__first == __last || *__first != ')')
throw regex_error(regex_constants::error_paren); throw regex_error(regex_constants::error_paren);
#endif
--__open_count_; --__open_count_;
++__first; ++__first;
} }
@@ -4089,8 +4168,10 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first,
unsigned __temp_count = __marked_count_; unsigned __temp_count = __marked_count_;
++__open_count_; ++__open_count_;
__first = __parse_ecma_exp(__first, __last); __first = __parse_ecma_exp(__first, __last);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last || *__first != ')') if (__first == __last || *__first != ')')
throw regex_error(regex_constants::error_paren); throw regex_error(regex_constants::error_paren);
#endif
__push_end_marked_subexpression(__temp_count); __push_end_marked_subexpression(__temp_count);
--__open_count_; --__open_count_;
++__first; ++__first;
@@ -4151,8 +4232,10 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first,
unsigned __v = *__first - '0'; unsigned __v = *__first - '0';
for (++__first; '0' <= *__first && *__first <= '9'; ++__first) for (++__first; '0' <= *__first && *__first <= '9'; ++__first)
__v = 10 * __v + *__first - '0'; __v = 10 * __v + *__first - '0';
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__v > mark_count()) if (__v > mark_count())
throw regex_error(regex_constants::error_backref); throw regex_error(regex_constants::error_backref);
#endif
__push_back_ref(__v); __push_back_ref(__v);
} }
} }
@@ -4270,31 +4353,51 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
} }
break; break;
case 'u': case 'u':
if (++__first == __last) ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
__hd = __traits_.value(*__first, 16); __hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1) if (__hd == -1)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
__sum = 16 * __sum + __hd; __sum = 16 * __sum + __hd;
if (++__first == __last) ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
__hd = __traits_.value(*__first, 16); __hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1) if (__hd == -1)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
__sum = 16 * __sum + __hd; __sum = 16 * __sum + __hd;
// drop through // drop through
case 'x': case 'x':
if (++__first == __last) ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
__hd = __traits_.value(*__first, 16); __hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1) if (__hd == -1)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
__sum = 16 * __sum + __hd; __sum = 16 * __sum + __hd;
if (++__first == __last) ++__first;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__first == __last)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
__hd = __traits_.value(*__first, 16); __hd = __traits_.value(*__first, 16);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__hd == -1) if (__hd == -1)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
__sum = 16 * __sum + __hd; __sum = 16 * __sum + __hd;
if (__str) if (__str)
*__str = _CharT(__sum); *__str = _CharT(__sum);
@@ -4311,8 +4414,10 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first,
__push_char(*__first); __push_char(*__first);
++__first; ++__first;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
else if (__str) else if (__str)
throw regex_error(regex_constants::error_escape); throw regex_error(regex_constants::error_escape);
#endif
break; break;
} }
} }
@@ -5206,8 +5311,11 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma(
__states.pop_back(); __states.pop_back();
break; break;
default: default:
#ifndef _LIBCPP_NO_EXCEPTIONS
throw regex_error(regex_constants::__re_err_unknown); throw regex_error(regex_constants::__re_err_unknown);
#endif
break; break;
} }
} while (!__states.empty()); } while (!__states.empty());
} }
@@ -5274,7 +5382,9 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
__states.pop_back(); __states.pop_back();
break; break;
default: default:
#ifndef _LIBCPP_NO_EXCEPTIONS
throw regex_error(regex_constants::__re_err_unknown); throw regex_error(regex_constants::__re_err_unknown);
#endif
break; break;
} }
} while (!__states.empty()); } while (!__states.empty());
@@ -5354,7 +5464,9 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
__states.pop_back(); __states.pop_back();
break; break;
default: default:
#ifndef _LIBCPP_NO_EXCEPTIONS
throw regex_error(regex_constants::__re_err_unknown); throw regex_error(regex_constants::__re_err_unknown);
#endif
break; break;
} }
} while (!__states.empty()); } while (!__states.empty());

View File

@@ -21,7 +21,7 @@ case $TRIPLE in
*-apple-*) *-apple-*)
if [ -z $RC_BUILDIT ] if [ -z $RC_BUILDIT ]
then then
RC_CFLAGS="-arch i386 -arch x86_64" RC_CFLAGS="-arch i386 -arch x86_64 -fno-exceptions -fno-rtti"
fi fi
SOEXT=dylib SOEXT=dylib
LDSHARED_FLAGS="-o libc++.1.dylib \ LDSHARED_FLAGS="-o libc++.1.dylib \

View File

@@ -54,15 +54,21 @@ std::set_terminate(std::terminate_handler func) throw()
void void
std::terminate() std::terminate()
{ {
try { #ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif
(*__terminate_handler)(); (*__terminate_handler)();
// handler should not return // handler should not return
::abort (); ::abort ();
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) { catch (...)
{
// handler should not throw exception // handler should not throw exception
::abort (); ::abort ();
} }
#endif
} }

View File

@@ -260,8 +260,10 @@ ios_base::clear(iostate state)
__rdstate_ = state; __rdstate_ = state;
else else
__rdstate_ = state | badbit; __rdstate_ = state | badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0) if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0)
throw failure("ios_base::clear"); throw failure("ios_base::clear");
#endif
} }
// init // init
@@ -300,23 +302,31 @@ ios_base::copyfmt(const ios_base& rhs)
if (__event_cap_ < rhs.__event_size_) if (__event_cap_ < rhs.__event_size_)
{ {
new_callbacks.reset((event_callback*)malloc(sizeof(event_callback) * rhs.__event_size_)); new_callbacks.reset((event_callback*)malloc(sizeof(event_callback) * rhs.__event_size_));
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!new_callbacks) if (!new_callbacks)
throw bad_alloc(); throw bad_alloc();
#endif
new_ints.reset((int*)malloc(sizeof(int) * rhs.__event_size_)); new_ints.reset((int*)malloc(sizeof(int) * rhs.__event_size_));
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!new_ints) if (!new_ints)
throw bad_alloc(); throw bad_alloc();
#endif
} }
if (__iarray_cap_ < rhs.__iarray_size_) if (__iarray_cap_ < rhs.__iarray_size_)
{ {
new_longs.reset((long*)malloc(sizeof(long) * rhs.__iarray_size_)); new_longs.reset((long*)malloc(sizeof(long) * rhs.__iarray_size_));
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!new_longs) if (!new_longs)
throw bad_alloc(); throw bad_alloc();
#endif
} }
if (__parray_cap_ < rhs.__parray_size_) if (__parray_cap_ < rhs.__parray_size_)
{ {
new_pointers.reset((void**)malloc(sizeof(void*) * rhs.__parray_size_)); new_pointers.reset((void**)malloc(sizeof(void*) * rhs.__parray_size_));
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!new_pointers) if (!new_pointers)
throw bad_alloc(); throw bad_alloc();
#endif
} }
// Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_ // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_
__fmtflags_ = rhs.__fmtflags_; __fmtflags_ = rhs.__fmtflags_;
@@ -417,16 +427,20 @@ void
ios_base::__set_badbit_and_consider_rethrow() ios_base::__set_badbit_and_consider_rethrow()
{ {
__rdstate_ |= badbit; __rdstate_ |= badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__exceptions_ & badbit) if (__exceptions_ & badbit)
throw; throw;
#endif
} }
void void
ios_base::__set_failbit_and_consider_rethrow() ios_base::__set_failbit_and_consider_rethrow()
{ {
__rdstate_ |= failbit; __rdstate_ |= failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__exceptions_ & failbit) if (__exceptions_ & failbit)
throw; throw;
#endif
} }
bool bool

View File

@@ -132,8 +132,10 @@ locale::__imp::__imp(const string& name, size_t refs)
name_(name), name_(name),
facets_(N) facets_(N)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
#endif
facets_ = locale::classic().__locale_->facets_; facets_ = locale::classic().__locale_->facets_;
for (unsigned i = 0; i < facets_.size(); ++i) for (unsigned i = 0; i < facets_.size(); ++i)
if (facets_[i]) if (facets_[i])
@@ -158,6 +160,7 @@ locale::__imp::__imp(const string& name, size_t refs)
install(new time_put_byname<wchar_t>(name_)); install(new time_put_byname<wchar_t>(name_));
install(new messages_byname<char>(name_)); install(new messages_byname<char>(name_));
install(new messages_byname<wchar_t>(name_)); install(new messages_byname<wchar_t>(name_));
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) catch (...)
{ {
@@ -166,6 +169,7 @@ locale::__imp::__imp(const string& name, size_t refs)
facets_[i]->__release_shared(); facets_[i]->__release_shared();
throw; throw;
} }
#endif
} }
locale::__imp::__imp(const __imp& other) locale::__imp::__imp(const __imp& other)
@@ -186,8 +190,10 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
for (unsigned i = 0; i < facets_.size(); ++i) for (unsigned i = 0; i < facets_.size(); ++i)
if (facets_[i]) if (facets_[i])
facets_[i]->__add_shared(); facets_[i]->__add_shared();
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
#endif
if (c & locale::collate) if (c & locale::collate)
{ {
install(new collate_byname<char>(name)); install(new collate_byname<char>(name));
@@ -226,6 +232,7 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
install(new messages_byname<char>(name)); install(new messages_byname<char>(name));
install(new messages_byname<wchar_t>(name)); install(new messages_byname<wchar_t>(name));
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) catch (...)
{ {
@@ -234,6 +241,7 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
facets_[i]->__release_shared(); facets_[i]->__release_shared();
throw; throw;
} }
#endif
} }
template<class F> template<class F>
@@ -253,8 +261,10 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
for (unsigned i = 0; i < facets_.size(); ++i) for (unsigned i = 0; i < facets_.size(); ++i)
if (facets_[i]) if (facets_[i])
facets_[i]->__add_shared(); facets_[i]->__add_shared();
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
#endif
if (c & locale::collate) if (c & locale::collate)
{ {
install_from<_STD::collate<char> >(one); install_from<_STD::collate<char> >(one);
@@ -301,6 +311,7 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
install_from<_STD::messages<char> >(one); install_from<_STD::messages<char> >(one);
install_from<_STD::messages<wchar_t> >(one); install_from<_STD::messages<wchar_t> >(one);
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) catch (...)
{ {
@@ -309,6 +320,7 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
facets_[i]->__release_shared(); facets_[i]->__release_shared();
throw; throw;
} }
#endif
} }
locale::__imp::__imp(const __imp& other, facet* f, long id) locale::__imp::__imp(const __imp& other, facet* f, long id)
@@ -346,8 +358,10 @@ locale::__imp::install(facet* f, long id)
const locale::facet* const locale::facet*
locale::__imp::use_facet(long id) const locale::__imp::use_facet(long id) const
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (!has_facet(id)) if (!has_facet(id))
throw bad_cast(); throw bad_cast();
#endif
return facets_[id]; return facets_[id];
} }
@@ -414,8 +428,12 @@ locale::operator=(const locale& other) throw()
} }
locale::locale(const char* name) locale::locale(const char* name)
#ifndef _LIBCPP_NO_EXCEPTIONS
: __locale_(name ? new __imp(name) : __locale_(name ? new __imp(name)
: throw runtime_error("locale constructed with null")) : throw runtime_error("locale constructed with null"))
#else
: __locale_(new __imp(name))
#endif
{ {
__locale_->__add_shared(); __locale_->__add_shared();
} }
@@ -427,8 +445,12 @@ locale::locale(const string& name)
} }
locale::locale(const locale& other, const char* name, category c) locale::locale(const locale& other, const char* name, category c)
#ifndef _LIBCPP_NO_EXCEPTIONS
: __locale_(name ? new __imp(*other.__locale_, name, c) : __locale_(name ? new __imp(*other.__locale_, name, c)
: throw runtime_error("locale constructed with null")) : throw runtime_error("locale constructed with null"))
#else
: __locale_(new __imp(*other.__locale_, name, c))
#endif
{ {
__locale_->__add_shared(); __locale_->__add_shared();
} }
@@ -545,18 +567,22 @@ collate_byname<char>::collate_byname(const char* n, size_t refs)
: collate<char>(refs), : collate<char>(refs),
__l(newlocale(LC_ALL_MASK, n, 0)) __l(newlocale(LC_ALL_MASK, n, 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__l == 0) if (__l == 0)
throw runtime_error("collate_byname<char>::collate_byname" throw runtime_error("collate_byname<char>::collate_byname"
" failed to construct for " + string(n)); " failed to construct for " + string(n));
#endif
} }
collate_byname<char>::collate_byname(const string& name, size_t refs) collate_byname<char>::collate_byname(const string& name, size_t refs)
: collate<char>(refs), : collate<char>(refs),
__l(newlocale(LC_ALL_MASK, name.c_str(), 0)) __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__l == 0) if (__l == 0)
throw runtime_error("collate_byname<char>::collate_byname" throw runtime_error("collate_byname<char>::collate_byname"
" failed to construct for " + name); " failed to construct for " + name);
#endif
} }
collate_byname<char>::~collate_byname() collate_byname<char>::~collate_byname()
@@ -593,18 +619,22 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
: collate<wchar_t>(refs), : collate<wchar_t>(refs),
__l(newlocale(LC_ALL_MASK, n, 0)) __l(newlocale(LC_ALL_MASK, n, 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__l == 0) if (__l == 0)
throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
" failed to construct for " + string(n)); " failed to construct for " + string(n));
#endif
} }
collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
: collate<wchar_t>(refs), : collate<wchar_t>(refs),
__l(newlocale(LC_ALL_MASK, name.c_str(), 0)) __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__l == 0) if (__l == 0)
throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
" failed to construct for " + name); " failed to construct for " + name);
#endif
} }
collate_byname<wchar_t>::~collate_byname() collate_byname<wchar_t>::~collate_byname()
@@ -828,18 +858,22 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs)
: ctype<char>(0, false, refs), : ctype<char>(0, false, refs),
__l(newlocale(LC_ALL_MASK, name, 0)) __l(newlocale(LC_ALL_MASK, name, 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__l == 0) if (__l == 0)
throw runtime_error("ctype_byname<char>::ctype_byname" throw runtime_error("ctype_byname<char>::ctype_byname"
" failed to construct for " + string(name)); " failed to construct for " + string(name));
#endif
} }
ctype_byname<char>::ctype_byname(const string& name, size_t refs) ctype_byname<char>::ctype_byname(const string& name, size_t refs)
: ctype<char>(0, false, refs), : ctype<char>(0, false, refs),
__l(newlocale(LC_ALL_MASK, name.c_str(), 0)) __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__l == 0) if (__l == 0)
throw runtime_error("ctype_byname<char>::ctype_byname" throw runtime_error("ctype_byname<char>::ctype_byname"
" failed to construct for " + name); " failed to construct for " + name);
#endif
} }
ctype_byname<char>::~ctype_byname() ctype_byname<char>::~ctype_byname()
@@ -881,18 +915,22 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
: ctype<wchar_t>(refs), : ctype<wchar_t>(refs),
__l(newlocale(LC_ALL_MASK, name, 0)) __l(newlocale(LC_ALL_MASK, name, 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__l == 0) if (__l == 0)
throw runtime_error("ctype_byname<wchar_t>::ctype_byname" throw runtime_error("ctype_byname<wchar_t>::ctype_byname"
" failed to construct for " + string(name)); " failed to construct for " + string(name));
#endif
} }
ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
: ctype<wchar_t>(refs), : ctype<wchar_t>(refs),
__l(newlocale(LC_ALL_MASK, name.c_str(), 0)) __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__l == 0) if (__l == 0)
throw runtime_error("ctype_byname<wchar_t>::ctype_byname" throw runtime_error("ctype_byname<wchar_t>::ctype_byname"
" failed to construct for " + name); " failed to construct for " + name);
#endif
} }
ctype_byname<wchar_t>::~ctype_byname() ctype_byname<wchar_t>::~ctype_byname()
@@ -1092,9 +1130,11 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
: locale::facet(refs), : locale::facet(refs),
__l(newlocale(LC_ALL_MASK, nm, 0)) __l(newlocale(LC_ALL_MASK, nm, 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__l == 0) if (__l == 0)
throw runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" throw runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
" failed to construct for " + string(nm)); " failed to construct for " + string(nm));
#endif
} }
codecvt<wchar_t, char, mbstate_t>::~codecvt() codecvt<wchar_t, char, mbstate_t>::~codecvt()
@@ -3832,9 +3872,11 @@ numpunct_byname<char>::__init(const char* nm)
if (strcmp(nm, "C") != 0) if (strcmp(nm, "C") != 0)
{ {
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (loc == 0) if (loc == 0)
throw runtime_error("numpunct_byname<char>::numpunct_byname" throw runtime_error("numpunct_byname<char>::numpunct_byname"
" failed to construct for " + string(nm)); " failed to construct for " + string(nm));
#endif
lconv* lc = localeconv_l(loc.get()); lconv* lc = localeconv_l(loc.get());
if (*lc->decimal_point) if (*lc->decimal_point)
__decimal_point_ = *lc->decimal_point; __decimal_point_ = *lc->decimal_point;
@@ -3869,9 +3911,11 @@ numpunct_byname<wchar_t>::__init(const char* nm)
if (strcmp(nm, "C") != 0) if (strcmp(nm, "C") != 0)
{ {
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (loc == 0) if (loc == 0)
throw runtime_error("numpunct_byname<char>::numpunct_byname" throw runtime_error("numpunct_byname<char>::numpunct_byname"
" failed to construct for " + string(nm)); " failed to construct for " + string(nm));
#endif
lconv* lc = localeconv_l(loc.get()); lconv* lc = localeconv_l(loc.get());
if (*lc->decimal_point) if (*lc->decimal_point)
__decimal_point_ = *lc->decimal_point; __decimal_point_ = *lc->decimal_point;
@@ -4274,17 +4318,21 @@ __time_get_c_storage<wchar_t>::__r() const
__time_get::__time_get(const char* nm) __time_get::__time_get(const char* nm)
: __loc_(newlocale(LC_ALL_MASK, nm, 0)) : __loc_(newlocale(LC_ALL_MASK, nm, 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__loc_ == 0) if (__loc_ == 0)
throw runtime_error("time_get_byname" throw runtime_error("time_get_byname"
" failed to construct for " + string(nm)); " failed to construct for " + string(nm));
#endif
} }
__time_get::__time_get(const string& nm) __time_get::__time_get(const string& nm)
: __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__loc_ == 0) if (__loc_ == 0)
throw runtime_error("time_get_byname" throw runtime_error("time_get_byname"
" failed to construct for " + nm); " failed to construct for " + nm);
#endif
} }
__time_get::~__time_get() __time_get::~__time_get()
@@ -4921,17 +4969,21 @@ __time_get_storage<wchar_t>::__do_date_order() const
__time_put::__time_put(const char* nm) __time_put::__time_put(const char* nm)
: __loc_(newlocale(LC_ALL_MASK, nm, 0)) : __loc_(newlocale(LC_ALL_MASK, nm, 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__loc_ == 0) if (__loc_ == 0)
throw runtime_error("time_put_byname" throw runtime_error("time_put_byname"
" failed to construct for " + string(nm)); " failed to construct for " + string(nm));
#endif
} }
__time_put::__time_put(const string& nm) __time_put::__time_put(const string& nm)
: __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__loc_ == 0) if (__loc_ == 0)
throw runtime_error("time_put_byname" throw runtime_error("time_put_byname"
" failed to construct for " + nm); " failed to construct for " + nm);
#endif
} }
__time_put::~__time_put() __time_put::~__time_put()
@@ -5210,9 +5262,11 @@ moneypunct_byname<char, false>::init(const char* nm)
{ {
typedef moneypunct<char, false> base; typedef moneypunct<char, false> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (loc == 0) if (loc == 0)
throw runtime_error("moneypunct_byname" throw runtime_error("moneypunct_byname"
" failed to construct for " + string(nm)); " failed to construct for " + string(nm));
#endif
lconv* lc = localeconv_l(loc.get()); lconv* lc = localeconv_l(loc.get());
if (*lc->mon_decimal_point) if (*lc->mon_decimal_point)
__decimal_point_ = *lc->mon_decimal_point; __decimal_point_ = *lc->mon_decimal_point;
@@ -5246,9 +5300,11 @@ moneypunct_byname<char, true>::init(const char* nm)
{ {
typedef moneypunct<char, true> base; typedef moneypunct<char, true> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (loc == 0) if (loc == 0)
throw runtime_error("moneypunct_byname" throw runtime_error("moneypunct_byname"
" failed to construct for " + string(nm)); " failed to construct for " + string(nm));
#endif
lconv* lc = localeconv_l(loc.get()); lconv* lc = localeconv_l(loc.get());
if (*lc->mon_decimal_point) if (*lc->mon_decimal_point)
__decimal_point_ = *lc->mon_decimal_point; __decimal_point_ = *lc->mon_decimal_point;
@@ -5282,9 +5338,11 @@ moneypunct_byname<wchar_t, false>::init(const char* nm)
{ {
typedef moneypunct<wchar_t, false> base; typedef moneypunct<wchar_t, false> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (loc == 0) if (loc == 0)
throw runtime_error("moneypunct_byname" throw runtime_error("moneypunct_byname"
" failed to construct for " + string(nm)); " failed to construct for " + string(nm));
#endif
lconv* lc = localeconv_l(loc.get()); lconv* lc = localeconv_l(loc.get());
if (*lc->mon_decimal_point) if (*lc->mon_decimal_point)
__decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point); __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
@@ -5341,9 +5399,11 @@ moneypunct_byname<wchar_t, true>::init(const char* nm)
{ {
typedef moneypunct<wchar_t, true> base; typedef moneypunct<wchar_t, true> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale); unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (loc == 0) if (loc == 0)
throw runtime_error("moneypunct_byname" throw runtime_error("moneypunct_byname"
" failed to construct for " + string(nm)); " failed to construct for " + string(nm));
#endif
lconv* lc = localeconv_l(loc.get()); lconv* lc = localeconv_l(loc.get());
if (*lc->mon_decimal_point) if (*lc->mon_decimal_point)
__decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point); __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
@@ -5398,7 +5458,9 @@ void __do_nothing(void*) {}
void __throw_runtime_error(const char* msg) void __throw_runtime_error(const char* msg)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw runtime_error(msg); throw runtime_error(msg);
#endif
} }
template class collate<char>; template class collate<char>;

View File

@@ -107,12 +107,16 @@ __shared_weak_count::lock()
return 0; return 0;
} }
#ifndef _LIBCPP_NO_RTTI
const void* const void*
__shared_weak_count::__get_deleter(const type_info&) const __shared_weak_count::__get_deleter(const type_info&) const
{ {
return 0; return 0;
} }
#endif
void void
declare_reachable(void*) declare_reachable(void*)
{ {

View File

@@ -220,8 +220,10 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
pthread_cond_wait(&cv, &mut); pthread_cond_wait(&cv, &mut);
if (flag == 0) if (flag == 0)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
#endif
flag = 1; flag = 1;
pthread_mutex_unlock(&mut); pthread_mutex_unlock(&mut);
func(arg); func(arg);
@@ -229,6 +231,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
flag = ~0ul; flag = ~0ul;
pthread_mutex_unlock(&mut); pthread_mutex_unlock(&mut);
pthread_cond_broadcast(&cv); pthread_cond_broadcast(&cv);
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) catch (...)
{ {
@@ -238,6 +241,7 @@ __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
pthread_cond_broadcast(&cv); pthread_cond_broadcast(&cv);
throw; throw;
} }
#endif
} }
else else
pthread_mutex_unlock(&mut); pthread_mutex_unlock(&mut);

View File

@@ -42,7 +42,11 @@ operator new(std::size_t size) throw (std::bad_alloc)
if (__new_handler) if (__new_handler)
__new_handler(); __new_handler();
else else
#ifndef _LIBCPP_NO_EXCEPTIONS
throw std::bad_alloc(); throw std::bad_alloc();
#else
break;
#endif
} }
return p; return p;
} }
@@ -52,13 +56,17 @@ void*
operator new(size_t size, const std::nothrow_t&) throw() operator new(size_t size, const std::nothrow_t&) throw()
{ {
void* p = 0; void* p = 0;
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
#endif
p = ::operator new(size); p = ::operator new(size);
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) catch (...)
{ {
} }
#endif
return p; return p;
} }
@@ -74,13 +82,17 @@ void*
operator new[](size_t size, const std::nothrow_t& nothrow) throw() operator new[](size_t size, const std::nothrow_t& nothrow) throw()
{ {
void* p = 0; void* p = 0;
#ifndef _LIBCPP_NO_EXCEPTIONS
try try
{ {
#endif
p = ::operator new[](size); p = ::operator new[](size);
#ifndef _LIBCPP_NO_EXCEPTIONS
} }
catch (...) catch (...)
{ {
} }
#endif
return p; return p;
} }
@@ -162,7 +174,9 @@ bad_array_new_length::what() const throw()
void void
__throw_bad_alloc() __throw_bad_alloc()
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_alloc(); throw bad_alloc();
#endif
} }
} // std } // std

View File

@@ -79,9 +79,11 @@ stoi(const string& str, size_t* idx, int base)
ptr = const_cast<char*>(p); ptr = const_cast<char*>(p);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stoi: no conversion"); throw invalid_argument("stoi: no conversion");
throw out_of_range("stoi: out of range"); throw out_of_range("stoi: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -98,9 +100,11 @@ stoi(const wstring& str, size_t* idx, int base)
ptr = const_cast<wchar_t*>(p); ptr = const_cast<wchar_t*>(p);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stoi: no conversion"); throw invalid_argument("stoi: no conversion");
throw out_of_range("stoi: out of range"); throw out_of_range("stoi: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -115,9 +119,11 @@ stol(const string& str, size_t* idx, int base)
long r = strtol(p, &ptr, base); long r = strtol(p, &ptr, base);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stol: no conversion"); throw invalid_argument("stol: no conversion");
throw out_of_range("stol: out of range"); throw out_of_range("stol: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -132,9 +138,11 @@ stol(const wstring& str, size_t* idx, int base)
long r = wcstol(p, &ptr, base); long r = wcstol(p, &ptr, base);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stol: no conversion"); throw invalid_argument("stol: no conversion");
throw out_of_range("stol: out of range"); throw out_of_range("stol: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -149,9 +157,11 @@ stoul(const string& str, size_t* idx, int base)
unsigned long r = strtoul(p, &ptr, base); unsigned long r = strtoul(p, &ptr, base);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stoul: no conversion"); throw invalid_argument("stoul: no conversion");
throw out_of_range("stoul: out of range"); throw out_of_range("stoul: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -166,9 +176,11 @@ stoul(const wstring& str, size_t* idx, int base)
unsigned long r = wcstoul(p, &ptr, base); unsigned long r = wcstoul(p, &ptr, base);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stoul: no conversion"); throw invalid_argument("stoul: no conversion");
throw out_of_range("stoul: out of range"); throw out_of_range("stoul: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -183,9 +195,11 @@ stoll(const string& str, size_t* idx, int base)
long long r = strtoll(p, &ptr, base); long long r = strtoll(p, &ptr, base);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stoll: no conversion"); throw invalid_argument("stoll: no conversion");
throw out_of_range("stoll: out of range"); throw out_of_range("stoll: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -200,9 +214,11 @@ stoll(const wstring& str, size_t* idx, int base)
long long r = wcstoll(p, &ptr, base); long long r = wcstoll(p, &ptr, base);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stoll: no conversion"); throw invalid_argument("stoll: no conversion");
throw out_of_range("stoll: out of range"); throw out_of_range("stoll: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -217,9 +233,11 @@ stoull(const string& str, size_t* idx, int base)
unsigned long long r = strtoull(p, &ptr, base); unsigned long long r = strtoull(p, &ptr, base);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stoull: no conversion"); throw invalid_argument("stoull: no conversion");
throw out_of_range("stoull: out of range"); throw out_of_range("stoull: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -234,9 +252,11 @@ stoull(const wstring& str, size_t* idx, int base)
unsigned long long r = wcstoull(p, &ptr, base); unsigned long long r = wcstoull(p, &ptr, base);
if (ptr == p) if (ptr == p)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
if (r == 0) if (r == 0)
throw invalid_argument("stoull: no conversion"); throw invalid_argument("stoull: no conversion");
throw out_of_range("stoull: out of range"); throw out_of_range("stoull: out of range");
#endif
} }
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
@@ -252,10 +272,12 @@ stof(const string& str, size_t* idx)
errno = 0; errno = 0;
double r = strtod(p, &ptr); double r = strtod(p, &ptr);
swap(errno, errno_save); swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (errno_save == ERANGE) if (errno_save == ERANGE)
throw out_of_range("stof: out of range"); throw out_of_range("stof: out of range");
if (ptr == p) if (ptr == p)
throw invalid_argument("stof: no conversion"); throw invalid_argument("stof: no conversion");
#endif
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
return static_cast<float>(r); return static_cast<float>(r);
@@ -270,10 +292,12 @@ stof(const wstring& str, size_t* idx)
errno = 0; errno = 0;
double r = wcstod(p, &ptr); double r = wcstod(p, &ptr);
swap(errno, errno_save); swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (errno_save == ERANGE) if (errno_save == ERANGE)
throw out_of_range("stof: out of range"); throw out_of_range("stof: out of range");
if (ptr == p) if (ptr == p)
throw invalid_argument("stof: no conversion"); throw invalid_argument("stof: no conversion");
#endif
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
return static_cast<float>(r); return static_cast<float>(r);
@@ -288,10 +312,12 @@ stod(const string& str, size_t* idx)
errno = 0; errno = 0;
double r = strtod(p, &ptr); double r = strtod(p, &ptr);
swap(errno, errno_save); swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (errno_save == ERANGE) if (errno_save == ERANGE)
throw out_of_range("stod: out of range"); throw out_of_range("stod: out of range");
if (ptr == p) if (ptr == p)
throw invalid_argument("stod: no conversion"); throw invalid_argument("stod: no conversion");
#endif
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
return r; return r;
@@ -306,10 +332,12 @@ stod(const wstring& str, size_t* idx)
errno = 0; errno = 0;
double r = wcstod(p, &ptr); double r = wcstod(p, &ptr);
swap(errno, errno_save); swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (errno_save == ERANGE) if (errno_save == ERANGE)
throw out_of_range("stod: out of range"); throw out_of_range("stod: out of range");
if (ptr == p) if (ptr == p)
throw invalid_argument("stod: no conversion"); throw invalid_argument("stod: no conversion");
#endif
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
return r; return r;
@@ -324,10 +352,12 @@ stold(const string& str, size_t* idx)
errno = 0; errno = 0;
long double r = strtold(p, &ptr); long double r = strtold(p, &ptr);
swap(errno, errno_save); swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (errno_save == ERANGE) if (errno_save == ERANGE)
throw out_of_range("stold: out of range"); throw out_of_range("stold: out of range");
if (ptr == p) if (ptr == p)
throw invalid_argument("stold: no conversion"); throw invalid_argument("stold: no conversion");
#endif
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
return r; return r;
@@ -342,10 +372,12 @@ stold(const wstring& str, size_t* idx)
errno = 0; errno = 0;
long double r = wcstold(p, &ptr); long double r = wcstold(p, &ptr);
swap(errno, errno_save); swap(errno, errno_save);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (errno_save == ERANGE) if (errno_save == ERANGE)
throw out_of_range("stold: out of range"); throw out_of_range("stold: out of range");
if (ptr == p) if (ptr == p)
throw invalid_argument("stold: no conversion"); throw invalid_argument("stold: no conversion");
#endif
if (idx) if (idx)
*idx = static_cast<size_t>(ptr - p); *idx = static_cast<size_t>(ptr - p);
return r; return r;

View File

@@ -193,7 +193,9 @@ system_error::~system_error() throw()
void void
__throw_system_error(int ev, const char* what_arg) __throw_system_error(int ev, const char* what_arg)
{ {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw system_error(error_code(ev, system_category()), what_arg); throw system_error(error_code(ev, system_category()), what_arg);
#endif
} }
_LIBCPP_END_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD

View File

@@ -24,8 +24,10 @@ void
thread::join() thread::join()
{ {
int ec = pthread_join(__t_, 0); int ec = pthread_join(__t_, 0);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (ec) if (ec)
throw system_error(error_code(ec, system_category()), "thread::join failed"); throw system_error(error_code(ec, system_category()), "thread::join failed");
#endif
__t_ = 0; __t_ = 0;
} }
@@ -39,8 +41,10 @@ thread::detach()
if (ec == 0) if (ec == 0)
__t_ = 0; __t_ = 0;
} }
#ifndef _LIBCPP_NO_EXCEPTIONS
if (ec) if (ec)
throw system_error(error_code(ec, system_category()), "thread::detach failed"); throw system_error(error_code(ec, system_category()), "thread::detach failed");
#endif
} }
unsigned unsigned