[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.22.27.222: ~ $
// <scoped_allocator> -*- C++ -*-

// Copyright (C) 2011-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file include/scoped_allocator
 *  This is a Standard C++ Library header.
 */

#ifndef _SCOPED_ALLOCATOR
#define _SCOPED_ALLOCATOR 1

#pragma GCC system_header

#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else

#include <utility>
#include <tuple>
#include <bits/alloc_traits.h>

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

  template<template<typename> class _Pred, typename... _Allocs>
    struct __any_of;

  template<template<typename> class _Pred, typename _Alloc, typename... _Allocs>
    struct __any_of<_Pred, _Alloc, _Allocs...>
    : __or_<_Pred<_Alloc>, __any_of<_Pred, _Allocs...>>
    { };

  template<template<typename> class _Pred, typename _Alloc>
    struct __any_of<_Pred, _Alloc>
    : _Pred<_Alloc>
    { };

  /**
   * @addtogroup allocators
   * @{
   */

  template<typename _Alloc>
    struct __propagate_on_copy
    : allocator_traits<_Alloc>::propagate_on_container_copy_assignment
    { };
  template<typename _Alloc>
    struct __propagate_on_move
    : allocator_traits<_Alloc>::propagate_on_container_move_assignment
    { };
  template<typename _Alloc>
    struct __propagate_on_swap
    : allocator_traits<_Alloc>::propagate_on_container_swap
    { };


  template<typename _Alloc>
    inline auto
    __do_outermost(_Alloc& __a, _Alloc*) -> decltype(__a.outer_allocator())
    { return __a.outer_allocator(); }

  template<typename _Alloc>
    inline _Alloc&
    __do_outermost(_Alloc& __a, ...)
    { return __a; }

  // TODO: make recursive (see note in 20.12.4/1)
  template<typename _Alloc>
    inline auto
    __outermost(_Alloc& __a) -> decltype(__do_outermost(__a, &__a))
    { return __do_outermost(__a, &__a); }

  template<typename _OuterAlloc, typename... _InnerAllocs>
    class scoped_allocator_adaptor;

  template<typename...> 
    struct __inner_type_impl;

  template<typename _Outer>
    struct __inner_type_impl<_Outer>
    {
      typedef scoped_allocator_adaptor<_Outer> __type;

      __inner_type_impl() = default;
      __inner_type_impl(const __inner_type_impl&) = default;
      __inner_type_impl(__inner_type_impl&&) = default;
      __inner_type_impl& operator=(const __inner_type_impl&) = default;
      __inner_type_impl& operator=(__inner_type_impl&&) = default;
      
      template<typename _Alloc>
      __inner_type_impl(const __inner_type_impl<_Alloc>& __other)
      { }
      
      template<typename _Alloc>
      __inner_type_impl(__inner_type_impl<_Alloc>&& __other)
      { }
      
      __type& 
      _M_get(__type* __p) noexcept { return *__p; }

      const __type& 
      _M_get(const __type* __p) const noexcept { return *__p; }
      
      tuple<> 
      _M_tie() const noexcept { return tuple<>(); }
      
      bool 
      operator==(const __inner_type_impl&) const noexcept
      { return true; }
    };

  template<typename _Outer, typename _InnerHead, typename... _InnerTail>
    struct __inner_type_impl<_Outer, _InnerHead, _InnerTail...>
    {
      typedef scoped_allocator_adaptor<_InnerHead, _InnerTail...> __type;
      
      __inner_type_impl() = default;
      __inner_type_impl(const __inner_type_impl&) = default;
      __inner_type_impl(__inner_type_impl&&) = default;
      __inner_type_impl& operator=(const __inner_type_impl&) = default;
      __inner_type_impl& operator=(__inner_type_impl&&) = default;
      
      template<typename... _Allocs>
      __inner_type_impl(const __inner_type_impl<_Allocs...>& __other)
      : _M_inner(__other._M_inner) { }
      
      template<typename... _Allocs>
      __inner_type_impl(__inner_type_impl<_Allocs...>&& __other)
      : _M_inner(std::move(__other._M_inner)) { }

    template<typename... _Args>
      explicit
      __inner_type_impl(_Args&&... __args)
      : _M_inner(std::forward<_Args>(__args)...) { }

      __type& 
      _M_get(void*) noexcept { return _M_inner; }
      
      const __type& 
      _M_get(const void*) const noexcept { return _M_inner; }
      
      tuple<const _InnerHead&, const _InnerTail&...> 
      _M_tie() const noexcept
      { return _M_inner._M_tie(); }
      
      bool 
      operator==(const __inner_type_impl& __other) const noexcept
      { return _M_inner == __other._M_inner; }
      
    private:
      template<typename...> friend class __inner_type_impl;
      template<typename, typename...> friend class scoped_allocator_adaptor;
      
      __type _M_inner;
    };

  /// Primary class template.
  template<typename _OuterAlloc, typename... _InnerAllocs>
    class scoped_allocator_adaptor
    : public _OuterAlloc
    {
      typedef allocator_traits<_OuterAlloc> __traits;

      typedef __inner_type_impl<_OuterAlloc, _InnerAllocs...> __inner_type;
      __inner_type _M_inner;

      template<typename _Outer, typename... _Inner>
        friend class scoped_allocator_adaptor;

      template<typename...>
        friend class __inner_type_impl;

      tuple<const _OuterAlloc&, const _InnerAllocs&...>
      _M_tie() const noexcept
      { return std::tuple_cat(std::tie(outer_allocator()), _M_inner._M_tie()); }

      template<typename _Alloc>
	using __outermost_type = typename
	  std::decay<decltype(__outermost(std::declval<_Alloc&>()))>::type;

      template<typename _Alloc>
	using __outermost_alloc_traits
	  = allocator_traits<__outermost_type<_Alloc>>;
      
      template<typename _Tp, typename... _Args>
        void 
        _M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args)
        {
	  typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
	  _O_traits::construct(__outermost(*this), __p,
			       std::forward<_Args>(__args)...);
        }

      typedef __uses_alloc1<typename __inner_type::__type> __uses_alloc1_;
      typedef __uses_alloc2<typename __inner_type::__type> __uses_alloc2_;

      template<typename _Tp, typename... _Args>
        void 
        _M_construct(__uses_alloc1_, _Tp* __p, _Args&&... __args)
        {
	  typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
	  _O_traits::construct(__outermost(*this), __p,
			       allocator_arg, inner_allocator(),
			       std::forward<_Args>(__args)...);
        }

      template<typename _Tp, typename... _Args>
        void 
        _M_construct(__uses_alloc2_, _Tp* __p, _Args&&... __args)
        {
	  typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
	  _O_traits::construct(__outermost(*this), __p,
			       std::forward<_Args>(__args)...,
			       inner_allocator());
        }

      template<typename _Alloc>
        static _Alloc
        _S_select_on_copy(const _Alloc& __a)
        {
          typedef allocator_traits<_Alloc> __a_traits;
          return __a_traits::select_on_container_copy_construction(__a);
        }

      template<std::size_t... _Indices>
        scoped_allocator_adaptor(tuple<const _OuterAlloc&,
                                       const _InnerAllocs&...> __refs,
                                 _Index_tuple<_Indices...>)
        : _OuterAlloc(_S_select_on_copy(std::get<0>(__refs))),
          _M_inner(_S_select_on_copy(std::get<_Indices+1>(__refs))...)
        { }

    public:
      typedef _OuterAlloc                       outer_allocator_type;
      typedef typename __inner_type::__type     inner_allocator_type;

      typedef typename __traits::value_type             value_type;
      typedef typename __traits::size_type              size_type;
      typedef typename __traits::difference_type        difference_type;
      typedef typename __traits::pointer                pointer;
      typedef typename __traits::const_pointer          const_pointer;
      typedef typename __traits::void_pointer           void_pointer;
      typedef typename __traits::const_void_pointer     const_void_pointer;

      typedef typename conditional<
        __any_of<__propagate_on_copy, _OuterAlloc, _InnerAllocs...>::value,
        true_type, false_type>::type propagate_on_container_copy_assignment;
      typedef typename conditional<
        __any_of<__propagate_on_move, _OuterAlloc, _InnerAllocs...>::value,
        true_type, false_type>::type propagate_on_container_move_assignment;
      typedef typename conditional<
        __any_of<__propagate_on_swap, _OuterAlloc, _InnerAllocs...>::value,
        true_type, false_type>::type propagate_on_container_swap;

      template <class _Tp>
        struct rebind
        {
          typedef scoped_allocator_adaptor<
            typename __traits::template rebind_alloc<_Tp>,
            _InnerAllocs...> other;
        };

      scoped_allocator_adaptor() : _OuterAlloc(), _M_inner() { }

      template<typename _Outer2>
        scoped_allocator_adaptor(_Outer2&& __outer,
                                 const _InnerAllocs&... __inner)
        : _OuterAlloc(std::forward<_Outer2>(__outer)),
          _M_inner(__inner...)
        { }

      scoped_allocator_adaptor(const scoped_allocator_adaptor& __other)
      : _OuterAlloc(__other.outer_allocator()),
	_M_inner(__other._M_inner)
      { }

      scoped_allocator_adaptor(scoped_allocator_adaptor&& __other)
      : _OuterAlloc(std::move(__other.outer_allocator())),
	_M_inner(std::move(__other._M_inner))
      { }

      template<typename _Outer2>
        scoped_allocator_adaptor(
            const scoped_allocator_adaptor<_Outer2, _InnerAllocs...>& __other)
        : _OuterAlloc(__other.outer_allocator()),
          _M_inner(__other._M_inner)
        { }

      template<typename _Outer2>
        scoped_allocator_adaptor(
            scoped_allocator_adaptor<_Outer2, _InnerAllocs...>&& __other)
        : _OuterAlloc(std::move(__other.outer_allocator())),
          _M_inner(std::move(__other._M_inner))
        { }

      scoped_allocator_adaptor&
      operator=(const scoped_allocator_adaptor&) = default;

      scoped_allocator_adaptor&
      operator=(scoped_allocator_adaptor&&) = default;

      inner_allocator_type& inner_allocator() noexcept
      { return _M_inner._M_get(this); }

      const inner_allocator_type& inner_allocator() const noexcept
      { return _M_inner._M_get(this); }

      outer_allocator_type& outer_allocator() noexcept
      { return static_cast<_OuterAlloc&>(*this); }

      const outer_allocator_type& outer_allocator() const noexcept
      { return static_cast<const _OuterAlloc&>(*this); }

      pointer allocate(size_type __n)
      { return __traits::allocate(outer_allocator(), __n); }

      pointer allocate(size_type __n, const_void_pointer __hint)
      { return __traits::allocate(outer_allocator(), __n, __hint); }

      void deallocate(pointer __p, size_type __n)
      { return __traits::deallocate(outer_allocator(), __p, __n); }

      size_type max_size() const
      { return __traits::max_size(outer_allocator()); }

      template<typename _Tp, typename... _Args>
        void construct(_Tp* __p, _Args&&... __args)
        {
          auto& __inner = inner_allocator();
          auto __use_tag
            = __use_alloc<_Tp, inner_allocator_type, _Args...>(__inner);
          _M_construct(__use_tag, __p, std::forward<_Args>(__args)...);
        }

      template<typename _T1, typename _T2, typename... _Args1,
	       typename... _Args2>
	void
	construct(pair<_T1, _T2>* __p, piecewise_construct_t,
		  tuple<_Args1...> __x, tuple<_Args2...> __y)
	{
	  // _GLIBCXX_RESOLVE_LIB_DEFECTS
	  // 2203.  wrong argument types for piecewise construction
	  auto& __inner = inner_allocator();
	  auto __x_use_tag
	    = __use_alloc<_T1, inner_allocator_type, _Args1...>(__inner);
	  auto __y_use_tag
	    = __use_alloc<_T2, inner_allocator_type, _Args2...>(__inner);
	  typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
	  _O_traits::construct(__outermost(*this), __p, piecewise_construct,
			       _M_construct_p(__x_use_tag, __x),
			       _M_construct_p(__y_use_tag, __y));
	}

      template<typename _T1, typename _T2>
	void
	construct(pair<_T1, _T2>* __p)
	{ construct(__p, piecewise_construct, tuple<>(), tuple<>()); }

      template<typename _T1, typename _T2, typename _Up, typename _Vp>
	void
	construct(pair<_T1, _T2>* __p, _Up&& __u, _Vp&& __v)
	{
	  construct(__p, piecewise_construct,
		    std::forward_as_tuple(std::forward<_Up>(__u)),
		    std::forward_as_tuple(std::forward<_Vp>(__v)));
	}

      template<typename _T1, typename _T2, typename _Up, typename _Vp>
	void
	construct(pair<_T1, _T2>* __p, const pair<_Up, _Vp>& __x)
	{
	  construct(__p, piecewise_construct,
		    std::forward_as_tuple(__x.first),
		    std::forward_as_tuple(__x.second));
	}

      template<typename _T1, typename _T2, typename _Up, typename _Vp>
	void
	construct(pair<_T1, _T2>* __p, pair<_Up, _Vp>&& __x)
	{
	  construct(__p, piecewise_construct,
		    std::forward_as_tuple(std::forward<_Up>(__x.first)),
		    std::forward_as_tuple(std::forward<_Vp>(__x.second)));
	}

      template<typename _Tp>
        void destroy(_Tp* __p)
        {
	  typedef __outermost_alloc_traits<scoped_allocator_adaptor> _O_traits;
	  _O_traits::destroy(__outermost(*this), __p);
	}

      scoped_allocator_adaptor
      select_on_container_copy_construction() const
      {
        typedef typename _Build_index_tuple<sizeof...(_InnerAllocs)>::__type
	    _Indices;
        return scoped_allocator_adaptor(_M_tie(), _Indices());
      }

      template <typename _OutA1, typename _OutA2, typename... _InA>
      friend bool
      operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
                 const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept;

    private:
      template<typename _Tuple>
	_Tuple&&
	_M_construct_p(__uses_alloc0, _Tuple& __t)
	{ return std::move(__t); }

      template<typename... _Args>
	std::tuple<allocator_arg_t, inner_allocator_type&, _Args...>
	_M_construct_p(__uses_alloc1_, std::tuple<_Args...>& __t)
	{
	  typedef std::tuple<allocator_arg_t, inner_allocator_type&> _Tuple;
	  return std::tuple_cat(_Tuple(allocator_arg, inner_allocator()),
				std::move(__t));
	}

      template<typename... _Args>
	std::tuple<_Args..., inner_allocator_type&>
	_M_construct_p(__uses_alloc2_, std::tuple<_Args...>& __t)
	{
	  typedef std::tuple<inner_allocator_type&> _Tuple;
	  return std::tuple_cat(std::move(__t), _Tuple(inner_allocator()));
	}
    };

  template <typename _OutA1, typename _OutA2, typename... _InA>
    inline bool
    operator==(const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
               const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept
    {
      return __a.outer_allocator() == __b.outer_allocator()
          && __a._M_inner == __b._M_inner;
    }

  template <typename _OutA1, typename _OutA2, typename... _InA>
    inline bool
    operator!=(const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
               const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept
    { return !(__a == __b); }

  /// @}

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

#endif // C++11

#endif // _SCOPED_ALLOCATOR

Filemanager

Name Type Size Permission Actions
backward Folder 0755
bits Folder 0755
debug Folder 0755
decimal Folder 0755
ext Folder 0755
parallel Folder 0755
profile Folder 0755
tr1 Folder 0755
tr2 Folder 0755
x86_64-redhat-linux Folder 0755
algorithm File 2.46 KB 0644
array File 9.27 KB 0644
atomic File 33.3 KB 0644
bitset File 44.55 KB 0644
cassert File 1.58 KB 0644
ccomplex File 1.29 KB 0644
cctype File 2.35 KB 0644
cerrno File 1.7 KB 0644
cfenv File 2 KB 0644
cfloat File 1.82 KB 0644
chrono File 23.04 KB 0644
cinttypes File 2.11 KB 0644
ciso646 File 1.46 KB 0644
climits File 1.84 KB 0644
clocale File 1.86 KB 0644
cmath File 41.45 KB 0644
complex File 51.29 KB 0644
complex.h File 1.43 KB 0644
condition_variable File 7.8 KB 0644
csetjmp File 1.9 KB 0644
csignal File 1.81 KB 0644
cstdalign File 1.37 KB 0644
cstdarg File 1.8 KB 0644
cstdbool File 1.37 KB 0644
cstddef File 1.57 KB 0644
cstdint File 2.12 KB 0644
cstdio File 4.18 KB 0644
cstdlib File 6.01 KB 0644
cstring File 3.05 KB 0644
ctgmath File 1.29 KB 0644
ctime File 2.08 KB 0644
cwchar File 6.34 KB 0644
cwctype File 2.73 KB 0644
cxxabi.h File 21.24 KB 0644
deque File 2.6 KB 0644
exception File 4.95 KB 0644
fenv.h File 1.97 KB 0644
forward_list File 1.54 KB 0644
fstream File 29.31 KB 0644
functional File 79.23 KB 0644
future File 41.7 KB 0644
initializer_list File 2.9 KB 0644
iomanip File 11.21 KB 0644
ios File 1.56 KB 0644
iosfwd File 6.69 KB 0644
iostream File 2.63 KB 0644
istream File 29.25 KB 0644
iterator File 2.58 KB 0644
limits File 65.68 KB 0644
list File 2.53 KB 0644
locale File 1.39 KB 0644
map File 2.5 KB 0644
memory File 2.81 KB 0644
mutex File 19.66 KB 0644
new File 4.09 KB 0644
numeric File 2.72 KB 0644
ostream File 19.19 KB 0644
queue File 2.41 KB 0644
random File 1.67 KB 0644
ratio File 18.69 KB 0644
regex File 1.82 KB 0644
scoped_allocator File 15.65 KB 0644
set File 2.5 KB 0644
sstream File 19.57 KB 0644
stack File 2.33 KB 0644
stdexcept File 4.61 KB 0644
streambuf File 28.71 KB 0644
string File 1.9 KB 0644
system_error File 10.11 KB 0644
tgmath.h File 1.33 KB 0644
thread File 7.08 KB 0644
tuple File 34.85 KB 0644
type_traits File 57.55 KB 0644
typeindex File 3.01 KB 0644
typeinfo File 7.5 KB 0644
unordered_map File 1.81 KB 0644
unordered_set File 1.81 KB 0644
utility File 5.22 KB 0644
valarray File 39.32 KB 0644
vector File 2.66 KB 0644