46 #ifndef _THROW_ALLOCATOR_H 
   47 #define _THROW_ALLOCATOR_H 1 
   58 #if __cplusplus >= 201103L 
   62 # include <tr1/functional> 
   63 # include <tr1/random> 
   66 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 
   68 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   79   __throw_forced_error()
 
  105     insert(
void* p, 
size_t size)
 
  109       std::string error(
"annotate_base::insert null insert!\n");
 
  110       log_to_string(error, make_entry(p, size));
 
  111       std::__throw_logic_error(error.
c_str());
 
  114       const_iterator found = map_alloc().
find(p);
 
  115       if (found != map_alloc().
end())
 
  117       std::string error(
"annotate_base::insert double insert!\n");
 
  118       log_to_string(error, make_entry(p, size));
 
  119       log_to_string(error, *found);
 
  120       std::__throw_logic_error(error.
c_str());
 
  123       map_alloc().
insert(make_entry(p, size));
 
  127     erase(
void* p, 
size_t size)
 
  129       check_allocated(p, size);
 
  130       map_alloc().
erase(p);
 
  133 #if __cplusplus >= 201103L 
  135     insert_construct(
void* p)
 
  139       std::string error(
"annotate_base::insert_construct null!\n");
 
  140       std::__throw_logic_error(error.
c_str());
 
  143       auto found = map_construct().
find(p);
 
  144       if (found != map_construct().
end())
 
  146       std::string error(
"annotate_base::insert_construct double insert!\n");
 
  148       log_to_string(error, *found);
 
  149       std::__throw_logic_error(error.
c_str());
 
  156     erase_construct(
void* p)
 
  158       check_constructed(p);
 
  159       map_construct().
erase(p);
 
  165     check_allocated(
void* p, 
size_t size)
 
  167       const_iterator found = map_alloc().
find(p);
 
  168       if (found == map_alloc().
end())
 
  170       std::string error(
"annotate_base::check_allocated by value " 
  172       log_to_string(error, make_entry(p, size));
 
  173       std::__throw_logic_error(error.
c_str());
 
  176       if (found->second.second != size)
 
  178       std::string error(
"annotate_base::check_allocated by value " 
  179                 "wrong-size erase!\n");
 
  180       log_to_string(error, make_entry(p, size));
 
  181       log_to_string(error, *found);
 
  182       std::__throw_logic_error(error.
c_str());
 
  192     const_iterator beg = map_alloc().
begin();
 
  193     const_iterator 
end = map_alloc().
end();
 
  196         if (beg->second.first == label)
 
  197           log_to_string(found, *beg);
 
  202 #if __cplusplus >= 201103L 
  204     auto beg = map_construct().
begin();
 
  205     auto end = map_construct().
end();
 
  208         if (beg->second == label)
 
  209           log_to_string(found, *beg);
 
  217       std::string error(
"annotate_base::check by label\n");
 
  219       std::__throw_logic_error(error.
c_str());
 
  229     const_iterator beg = map_alloc().
begin();
 
  230     const_iterator 
end = map_alloc().
end();
 
  233         log_to_string(found, *beg);
 
  238 #if __cplusplus >= 201103L 
  240     auto beg = map_construct().
begin();
 
  241     auto end = map_construct().
end();
 
  244         log_to_string(found, *beg);
 
  254       std::__throw_logic_error(error.
c_str());
 
  258 #if __cplusplus >= 201103L 
  260     check_constructed(
void* p)
 
  262       auto found = map_construct().
find(p);
 
  263       if (found == map_construct().
end())
 
  265       std::string error(
"annotate_base::check_constructed not " 
  268       std::__throw_logic_error(error.
c_str());
 
  273     check_constructed(
size_t label)
 
  275       auto beg = map_construct().
begin();
 
  276       auto end = map_construct().
end();
 
  280       if (beg->second == label)
 
  281         log_to_string(found, *beg);
 
  287       std::string error(
"annotate_base::check_constructed by label\n");
 
  289       std::__throw_logic_error(error.
c_str());
 
  298     typedef map_alloc_type::const_iterator      const_iterator;
 
  299     typedef map_alloc_type::const_reference         const_reference;
 
  300 #if __cplusplus >= 201103L 
  308     make_entry(
void* p, 
size_t size)
 
  315       const char tab(
'\t');
 
  317       unsigned long l = 
static_cast<unsigned long>(ref.second.first);
 
  318       __builtin_sprintf(buf, 
"%lu", l);
 
  322       l = 
static_cast<unsigned long>(ref.second.second);
 
  323       __builtin_sprintf(buf, 
"%lu", l);
 
  327       __builtin_sprintf(buf, 
"%p", ref.first);
 
  332 #if __cplusplus >= 201103L 
  337       const char tab(
'\t');
 
  339       unsigned long l = 
static_cast<unsigned long>(ref.
second);
 
  340       __builtin_sprintf(buf, 
"%lu", l);
 
  344       __builtin_sprintf(buf, 
"%p", ref.
first);
 
  364 #if __cplusplus >= 201103L 
  380       base_type::const_iterator beg = __b.map_alloc().
begin();
 
  381       base_type::const_iterator 
end = __b.map_alloc().
end();
 
  382       for (; beg != 
end; ++beg)
 
  383     __b.log_to_string(error, *beg);
 
  385 #if __cplusplus >= 201103L 
  387       auto beg = __b.map_construct().
begin();
 
  388       auto end = __b.map_construct().
end();
 
  389       for (; beg != 
end; ++beg)
 
  390     __b.log_to_string(error, *beg);      
 
  420       const size_t _M_orig;
 
  423       adjustor_base() : _M_orig(limit()) { }
 
  426       ~adjustor_base() { set_limit(_M_orig); }
 
  450     throw_conditionally()
 
  452       if (count() == limit())
 
  453     __throw_forced_error();
 
  460       static size_t _S_count(0);
 
  473     set_limit(
const size_t __l)
 
  492       const double _M_orig;
 
  495       adjustor_base() : _M_orig(probability()) { }
 
  497       virtual ~adjustor_base()
 
  498       { set_probability(_M_orig); }
 
  505       { set_probability(1 - 
std::pow(
double(1 - probability()),
 
  506                      double(0.5 / (size + 1))));
 
  529     set_probability(
double __p)
 
  530     { probability() = __p; }
 
  533     throw_conditionally()
 
  535       if (generate() < probability())
 
  536     __throw_forced_error();
 
  540     seed(
unsigned long __s)
 
  541     { engine().seed(__s); }
 
  544 #if __cplusplus >= 201103L 
  548     typedef std::tr1::uniform_real<double>      distribution_type;
 
  555 #if __cplusplus >= 201103L 
  556       const distribution_type distribution(0, 1);
 
  557       static auto generator = 
std::bind(distribution, engine());
 
  560       typedef std::tr1::variate_generator<engine_type, distribution_type> gen_t;
 
  561       distribution_type distribution(0, 1);
 
  562       static gen_t generator(engine(), distribution);
 
  565       double random = generator();
 
  566       if (random < distribution.min() || random > distribution.max())
 
  570       __s += 
"random number generated is: ";
 
  572       __builtin_sprintf(buf, 
"%f", random);
 
  574       std::__throw_out_of_range(__s.c_str());
 
  590       static engine_type _S_e;
 
  602   template<
typename _Cond>
 
  605       typedef _Cond                 condition_type;
 
  607       using condition_type::throw_conditionally;
 
  611 #ifndef _GLIBCXX_IS_AGGREGATE 
  613       { throw_conditionally(); }
 
  616       { throw_conditionally(); }
 
  618 #if __cplusplus >= 201103L 
  624       { throw_conditionally(); }
 
  630     throw_conditionally();
 
  635 #if __cplusplus >= 201103L 
  644     throw_conditionally();
 
  650   template<
typename _Cond>
 
  655       throw_value::throw_conditionally();
 
  656       throw_value orig(__a);
 
  662   template<
typename _Cond>
 
  664     operator==(
const throw_value_base<_Cond>& __a,
 
  665            const throw_value_base<_Cond>& __b)
 
  667       typedef throw_value_base<_Cond> throw_value;
 
  668       throw_value::throw_conditionally();
 
  669       bool __ret = __a._M_i == __b._M_i;
 
  673   template<
typename _Cond>
 
  675     operator<(const throw_value_base<_Cond>& __a,
 
  676           const throw_value_base<_Cond>& __b)
 
  678       typedef throw_value_base<_Cond> throw_value;
 
  679       throw_value::throw_conditionally();
 
  680       bool __ret = __a._M_i < __b._M_i;
 
  685   template<
typename _Cond>
 
  686     inline throw_value_base<_Cond>
 
  687     operator+(
const throw_value_base<_Cond>& __a,
 
  688           const throw_value_base<_Cond>& __b)
 
  690       typedef throw_value_base<_Cond> throw_value;
 
  691       throw_value::throw_conditionally();
 
  692       throw_value __ret(__a._M_i + __b._M_i);
 
  696   template<
typename _Cond>
 
  697     inline throw_value_base<_Cond>
 
  698     operator-(
const throw_value_base<_Cond>& __a,
 
  699           const throw_value_base<_Cond>& __b)
 
  701       typedef throw_value_base<_Cond> throw_value;
 
  702       throw_value::throw_conditionally();
 
  703       throw_value __ret(__a._M_i - __b._M_i);
 
  707   template<
typename _Cond>
 
  708     inline throw_value_base<_Cond>
 
  709     operator*(
const throw_value_base<_Cond>& __a,
 
  710           const throw_value_base<_Cond>& __b)
 
  712       typedef throw_value_base<_Cond> throw_value;
 
  713       throw_value::throw_conditionally();
 
  714       throw_value __ret(__a._M_i * __b._M_i);
 
  724 #ifndef _GLIBCXX_IS_AGGREGATE 
  728     : base_type(__other._M_i) { }
 
  730 #if __cplusplus >= 201103L 
  740       base_type::operator=(__other);
 
  744 #if __cplusplus >= 201103L 
  755 #ifndef _GLIBCXX_IS_AGGREGATE 
  759     : base_type(__other._M_i) { }
 
  761 #if __cplusplus >= 201103L 
  771       base_type::operator=(__other);
 
  775 #if __cplusplus >= 201103L 
  789   template<
typename _Tp, 
typename _Cond>
 
  794       typedef size_t                size_type;
 
  795       typedef ptrdiff_t             difference_type;
 
  796       typedef _Tp               value_type;
 
  797       typedef value_type*           pointer;
 
  798       typedef const value_type*         const_pointer;
 
  799       typedef value_type&           reference;
 
  800       typedef const value_type&         const_reference;
 
  802 #if __cplusplus >= 201103L 
  809       typedef _Cond             condition_type;
 
  813       using condition_type::throw_conditionally;
 
  817       max_size() 
const _GLIBCXX_USE_NOEXCEPT
 
  818       { 
return _M_allocator.max_size(); }
 
  821       address(reference __x) 
const _GLIBCXX_NOEXCEPT
 
  825       address(const_reference __x) 
const _GLIBCXX_NOEXCEPT
 
  831     if (__n > this->max_size())
 
  832       std::__throw_bad_alloc();
 
  834     throw_conditionally();
 
  835     pointer 
const a = _M_allocator.allocate(__n, hint);
 
  836     insert(a, 
sizeof(value_type) * __n);
 
  840 #if __cplusplus >= 201103L 
  841       template<
typename _Up, 
typename... _Args>
 
  843         construct(_Up* __p, _Args&&... __args)
 
  845       _M_allocator.construct(__p, std::forward<_Args>(__args)...);
 
  846       insert_construct(__p);
 
  849       template<
typename _Up>
 
  853       erase_construct(__p);
 
  854       _M_allocator.destroy(__p);
 
  858       construct(pointer __p, 
const value_type& val)
 
  859       { 
return _M_allocator.construct(__p, val); }
 
  863       { _M_allocator.destroy(__p); }
 
  867       deallocate(pointer __p, size_type __n)
 
  869     erase(__p, 
sizeof(value_type) * __n);
 
  870     _M_allocator.deallocate(__p, __n);
 
  874       check_allocated(pointer __p, size_type __n)
 
  876     size_type __t = 
sizeof(value_type) * __n;
 
  877     annotate_base::check_allocated(__p, __t);
 
  882       { annotate_base::check(__n); }
 
  885   template<
typename _Tp, 
typename _Cond>
 
  891   template<
typename _Tp, 
typename _Cond>
 
  893     operator!=(
const throw_allocator_base<_Tp, _Cond>&,
 
  894            const throw_allocator_base<_Tp, _Cond>&)
 
  898   template<
typename _Tp>
 
  902       template<
typename _Tp1>
 
  909       _GLIBCXX_USE_NOEXCEPT { }
 
  911       template<
typename _Tp1>
 
  913     _GLIBCXX_USE_NOEXCEPT { }
 
  919   template<
typename _Tp>
 
  923       template<
typename _Tp1>
 
  930       _GLIBCXX_USE_NOEXCEPT { }
 
  932       template<
typename _Tp1>
 
  934     _GLIBCXX_USE_NOEXCEPT { }
 
  939 _GLIBCXX_END_NAMESPACE_VERSION
 
  942 #if __cplusplus >= 201103L 
  946 namespace std _GLIBCXX_VISIBILITY(default)
 
  950     struct hash<__gnu_cxx::throw_value_limit>
 
  956     __gnu_cxx::throw_value_limit::throw_conditionally();
 
  958     size_t __result = __h(__val._M_i);
 
  965     struct hash<__gnu_cxx::throw_value_random>
 
  971     __gnu_cxx::throw_value_random::throw_conditionally();
 
  973     size_t __result = __h(__val._M_i);
 
reference_wrapper< _Tp > ref(_Tp &__t) noexcept
Denotes a reference should be taken to a variable. 
 
_T2 second
first is a copy of the first object 
 
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents. 
 
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects. 
 
Allocator throwing via random condition. 
 
iterator find(const key_type &__x)
Tries to locate an element in a map. 
 
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map. 
 
_T1 first
second_type is the second bound type 
 
constexpr size_t size() const noexcept
Returns the total number of bits. 
 
Type throwing via random condition. 
 
Struct holding two objects of arbitrary type. 
 
Base class for all library exceptions. 
 
Never enter the condition. 
 
Properties of fundamental types. 
 
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power. 
 
bool empty() const noexcept
 
Allocator throwing via limit condition. 
 
Never enter the condition. 
 
Base struct for condition policy. 
 
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
 
Always enter the condition. 
 
Thown by exception safety machinery. 
 
_Bind_helper< __is_socketlike< _Func >::value, _Func, _BoundArgs...>::type bind(_Func &&__f, _BoundArgs &&...__args)
Function template for std::bind. 
 
Type throwing via limit condition. 
 
Base class for incremental control and throw. 
 
iterator begin() noexcept
 
Allocator class with logging and exception generation control. Intended to be used as an allocator_ty...
 
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
 
Base class for random probability control and throw. 
 
Base class for checking address and label information about allocations. Create a std::map between th...
 
mersenne_twister_engine< uint_fast32_t, 32, 624, 397, 31, 0x9908b0dfUL, 11, 0xffffffffUL, 7, 0x9d2c5680UL, 15, 0xefc60000UL, 18, 1812433253UL > mt19937
 
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof. 
 
Class with exception generation control. Intended to be used as a value_type in templatized code...
 
iterator erase(const_iterator __position)
Erases an element from a map. 
 
std::mersenne_twister_engine< uint_fast32_t, 32, 624, 397, 31, 0x9908b0dfUL, 11, 0xffffffffUL, 7, 0x9d2c5680UL, 15, 0xefc60000UL, 18, 1812433253UL >  
Always enter the condition. 
 
Uniform continuous distribution for random numbers. 
 
Primary class template hash.