summaryrefslogtreecommitdiffstats
path: root/include/bitset
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2016-08-25 15:09:01 +0000
committerMarshall Clow <mclow.lists@gmail.com>2016-08-25 15:09:01 +0000
commit14c09a2413ed5cc4914d1690f5dbfb9420a45b3c (patch)
tree8f7149218fefcbce3abf3ec60f3d31c126d9f63d /include/bitset
parentfdb4f1713ece3c6f7fbf98f3ea3f8c19fa0c249e (diff)
downloadexternal_libcxx-14c09a2413ed5cc4914d1690f5dbfb9420a45b3c.tar.gz
external_libcxx-14c09a2413ed5cc4914d1690f5dbfb9420a45b3c.tar.bz2
external_libcxx-14c09a2413ed5cc4914d1690f5dbfb9420a45b3c.zip
Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception type we define. They either construct and throw the exception, or abort() (if exceptions are disabled). Use these functions everywhere instead of assert()ing when exceptions are disabled. WARNING: This is a behavior change - but only with exceptions disabled. Reviewed as: https://reviews.llvm.org/D23855.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279744 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/bitset')
-rw-r--r--include/bitset66
1 files changed, 18 insertions, 48 deletions
diff --git a/include/bitset b/include/bitset
index 3f9b964e4..2ad9545f0 100644
--- a/include/bitset
+++ b/include/bitset
@@ -125,9 +125,6 @@ template <size_t N> struct hash<std::bitset<N>>;
#include <stdexcept>
#include <iosfwd>
#include <__functional_base>
-#if defined(_LIBCPP_NO_EXCEPTIONS)
- #include <cassert>
-#endif
#include <__undef_min_max>
@@ -326,11 +323,8 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const
const_iterator __e = __make_iter(_Size);
const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
if (__i != __e)
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw overflow_error("bitset to_ulong overflow error");
-#else
- assert(!"bitset to_ulong overflow error");
-#endif
+ __throw_overflow_error("bitset to_ulong overflow error");
+
return __first_[0];
}
@@ -349,11 +343,8 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const
const_iterator __e = __make_iter(_Size);
const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
if (__i != __e)
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw overflow_error("bitset to_ullong overflow error");
-#else
- assert(!"bitset to_ullong overflow error");
-#endif
+ __throw_overflow_error("bitset to_ullong overflow error");
+
return to_ullong(true_type());
}
@@ -763,11 +754,8 @@ bitset<_Size>::bitset(const _CharT* __str,
size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str));
for (size_t __i = 0; __i < __rlen; ++__i)
if (__str[__i] != __zero && __str[__i] != __one)
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw invalid_argument("bitset string ctor has invalid argument");
-#else
- assert(!"bitset string ctor has invalid argument");
-#endif
+ __throw_invalid_argument("bitset string ctor has invalid argument");
+
size_t _Mp = _VSTD::min(__rlen, _Size);
size_t __i = 0;
for (; __i < _Mp; ++__i)
@@ -789,19 +777,13 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str,
_CharT __zero, _CharT __one)
{
if (__pos > __str.size())
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw out_of_range("bitset string pos out of range");
-#else
- assert(!"bitset string pos out of range");
-#endif
+ __throw_out_of_range("bitset string pos out of range");
+
size_t __rlen = _VSTD::min(__n, __str.size() - __pos);
for (size_t __i = __pos; __i < __pos + __rlen; ++__i)
if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one))
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw invalid_argument("bitset string ctor has invalid argument");
-#else
- assert(!"bitset string ctor has invalid argument");
-#endif
+ __throw_invalid_argument("bitset string ctor has invalid argument");
+
size_t _Mp = _VSTD::min(__rlen, _Size);
size_t __i = 0;
for (; __i < _Mp; ++__i)
@@ -876,11 +858,8 @@ bitset<_Size>&
bitset<_Size>::set(size_t __pos, bool __val)
{
if (__pos >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw out_of_range("bitset set argument out of range");
-#else
- assert(!"bitset set argument out of range");
-#endif
+ __throw_out_of_range("bitset set argument out of range");
+
(*this)[__pos] = __val;
return *this;
}
@@ -899,11 +878,8 @@ bitset<_Size>&
bitset<_Size>::reset(size_t __pos)
{
if (__pos >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw out_of_range("bitset reset argument out of range");
-#else
- assert(!"bitset reset argument out of range");
-#endif
+ __throw_out_of_range("bitset reset argument out of range");
+
(*this)[__pos] = false;
return *this;
}
@@ -932,11 +908,8 @@ bitset<_Size>&
bitset<_Size>::flip(size_t __pos)
{
if (__pos >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw out_of_range("bitset flip argument out of range");
-#else
- assert(!"bitset flip argument out of range");
-#endif
+ __throw_out_of_range("bitset flip argument out of range");
+
reference r = base::__make_ref(__pos);
r = ~r;
return *this;
@@ -1027,11 +1000,8 @@ bool
bitset<_Size>::test(size_t __pos) const
{
if (__pos >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
- throw out_of_range("bitset test argument out of range");
-#else
- assert(!"bitset test argument out of range");
-#endif
+ __throw_out_of_range("bitset test argument out of range");
+
return (*this)[__pos];
}