aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libstdc++-v3/include/std
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/libstdc++-v3/include/std')
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/algorithm68
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/array337
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/atomic1126
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/bitset1595
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/chrono914
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/complex1966
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/condition_variable296
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/deque76
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/forward_list52
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/fstream941
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/functional2542
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/future1583
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/iomanip531
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/ios46
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/iosfwd210
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/iostream79
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/istream881
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/iterator70
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/limits1786
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/list75
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/locale43
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/map73
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/memory90
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/mutex767
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/numeric77
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/ostream611
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/queue66
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/random57
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/ratio538
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/regex65
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/scoped_allocator463
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/set73
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/shared_mutex399
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/sstream602
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/stack63
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/stdexcept158
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/streambuf830
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/string55
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/system_error381
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/thread302
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/tuple1104
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/type_traits2236
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/typeindex112
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/unordered_map61
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/unordered_set60
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/utility263
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/valarray1235
-rw-r--r--gcc-4.9/libstdc++-v3/include/std/vector81
48 files changed, 26039 insertions, 0 deletions
diff --git a/gcc-4.9/libstdc++-v3/include/std/algorithm b/gcc-4.9/libstdc++-v3/include/std/algorithm
new file mode 100644
index 0000000..ee1cd94
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/algorithm
@@ -0,0 +1,68 @@
+// <algorithm> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/algorithm
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_ALGORITHM
+#define _GLIBCXX_ALGORITHM 1
+
+#pragma GCC system_header
+
+#include <utility> // UK-300.
+#include <bits/stl_algobase.h>
+#include <bits/stl_algo.h>
+
+#ifdef _GLIBCXX_PARALLEL
+# include <parallel/algorithm>
+#endif
+
+#endif /* _GLIBCXX_ALGORITHM */
diff --git a/gcc-4.9/libstdc++-v3/include/std/array b/gcc-4.9/libstdc++-v3/include/std/array
new file mode 100644
index 0000000..67680d6
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/array
@@ -0,0 +1,337 @@
+// <array> -*- C++ -*-
+
+// Copyright (C) 2007-2014 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/array
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_ARRAY
+#define _GLIBCXX_ARRAY 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <stdexcept>
+#include <bits/stl_algobase.h>
+#include <bits/range_access.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
+
+ template<typename _Tp, std::size_t _Nm>
+ struct __array_traits
+ {
+ typedef _Tp _Type[_Nm];
+
+ static constexpr _Tp&
+ _S_ref(const _Type& __t, std::size_t __n) noexcept
+ { return const_cast<_Tp&>(__t[__n]); }
+ };
+
+ template<typename _Tp>
+ struct __array_traits<_Tp, 0>
+ {
+ struct _Type { };
+
+ static constexpr _Tp&
+ _S_ref(const _Type&, std::size_t) noexcept
+ { return *static_cast<_Tp*>(nullptr); }
+ };
+
+ /**
+ * @brief A standard container for storing a fixed size sequence of elements.
+ *
+ * @ingroup sequences
+ *
+ * Meets the requirements of a <a href="tables.html#65">container</a>, a
+ * <a href="tables.html#66">reversible container</a>, and a
+ * <a href="tables.html#67">sequence</a>.
+ *
+ * Sets support random access iterators.
+ *
+ * @tparam Tp Type of element. Required to be a complete type.
+ * @tparam N Number of elements.
+ */
+ template<typename _Tp, std::size_t _Nm>
+ struct array
+ {
+ typedef _Tp value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef value_type* iterator;
+ typedef const value_type* const_iterator;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ // Support for zero-sized arrays mandatory.
+ typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
+ typename _AT_Type::_Type _M_elems;
+
+ // No explicit construct/copy/destroy for aggregate type.
+
+ // DR 776.
+ void
+ fill(const value_type& __u)
+ { std::fill_n(begin(), size(), __u); }
+
+ void
+ swap(array& __other)
+ noexcept(noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())))
+ { std::swap_ranges(begin(), end(), __other.begin()); }
+
+ // Iterators.
+ iterator
+ begin() noexcept
+ { return iterator(data()); }
+
+ const_iterator
+ begin() const noexcept
+ { return const_iterator(data()); }
+
+ iterator
+ end() noexcept
+ { return iterator(data() + _Nm); }
+
+ const_iterator
+ end() const noexcept
+ { return const_iterator(data() + _Nm); }
+
+ reverse_iterator
+ rbegin() noexcept
+ { return reverse_iterator(end()); }
+
+ const_reverse_iterator
+ rbegin() const noexcept
+ { return const_reverse_iterator(end()); }
+
+ reverse_iterator
+ rend() noexcept
+ { return reverse_iterator(begin()); }
+
+ const_reverse_iterator
+ rend() const noexcept
+ { return const_reverse_iterator(begin()); }
+
+ const_iterator
+ cbegin() const noexcept
+ { return const_iterator(data()); }
+
+ const_iterator
+ cend() const noexcept
+ { return const_iterator(data() + _Nm); }
+
+ const_reverse_iterator
+ crbegin() const noexcept
+ { return const_reverse_iterator(end()); }
+
+ const_reverse_iterator
+ crend() const noexcept
+ { return const_reverse_iterator(begin()); }
+
+ // Capacity.
+ constexpr size_type
+ size() const noexcept { return _Nm; }
+
+ constexpr size_type
+ max_size() const noexcept { return _Nm; }
+
+ constexpr bool
+ empty() const noexcept { return size() == 0; }
+
+ // Element access.
+ reference
+ operator[](size_type __n) noexcept
+ { return _AT_Type::_S_ref(_M_elems, __n); }
+
+ constexpr const_reference
+ operator[](size_type __n) const noexcept
+ { return _AT_Type::_S_ref(_M_elems, __n); }
+
+ reference
+ at(size_type __n)
+ {
+ if (__n >= _Nm)
+ std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
+ ">= _Nm (which is %zu)"),
+ __n, _Nm);
+ return _AT_Type::_S_ref(_M_elems, __n);
+ }
+
+ constexpr const_reference
+ at(size_type __n) const
+ {
+ // Result of conditional expression must be an lvalue so use
+ // boolean ? lvalue : (throw-expr, lvalue)
+ return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
+ : (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
+ ">= _Nm (which is %zu)"),
+ __n, _Nm),
+ _AT_Type::_S_ref(_M_elems, 0));
+ }
+
+ reference
+ front() noexcept
+ { return *begin(); }
+
+ constexpr const_reference
+ front() const noexcept
+ { return _AT_Type::_S_ref(_M_elems, 0); }
+
+ reference
+ back() noexcept
+ { return _Nm ? *(end() - 1) : *end(); }
+
+ constexpr const_reference
+ back() const noexcept
+ {
+ return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
+ : _AT_Type::_S_ref(_M_elems, 0);
+ }
+
+ pointer
+ data() noexcept
+ { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
+
+ const_pointer
+ data() const noexcept
+ { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
+ };
+
+ // Array comparisons.
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return std::equal(__one.begin(), __one.end(), __two.begin()); }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return !(__one == __two); }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
+ {
+ return std::lexicographical_compare(__a.begin(), __a.end(),
+ __b.begin(), __b.end());
+ }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return __two < __one; }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return !(__one > __two); }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return !(__one < __two); }
+
+ // Specialized algorithms.
+ template<typename _Tp, std::size_t _Nm>
+ inline void
+ swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
+ noexcept(noexcept(__one.swap(__two)))
+ { __one.swap(__two); }
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ constexpr _Tp&
+ get(array<_Tp, _Nm>& __arr) noexcept
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
+ _S_ref(__arr._M_elems, _Int);
+ }
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ constexpr _Tp&&
+ get(array<_Tp, _Nm>&& __arr) noexcept
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ return std::move(get<_Int>(__arr));
+ }
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ constexpr const _Tp&
+ get(const array<_Tp, _Nm>& __arr) noexcept
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
+ _S_ref(__arr._M_elems, _Int);
+ }
+
+_GLIBCXX_END_NAMESPACE_CONTAINER
+} // namespace std
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // Tuple interface to class template array.
+
+ /// tuple_size
+ template<typename _Tp>
+ class tuple_size;
+
+ template<typename _Tp, std::size_t _Nm>
+ struct tuple_size<_GLIBCXX_STD_C::array<_Tp, _Nm>>
+ : public integral_constant<std::size_t, _Nm> { };
+
+ /// tuple_element
+ template<std::size_t _Int, typename _Tp>
+ class tuple_element;
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ struct tuple_element<_Int, _GLIBCXX_STD_C::array<_Tp, _Nm>>
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ typedef _Tp type;
+ };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/array>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/array>
+#endif
+
+#endif // C++11
+
+#endif // _GLIBCXX_ARRAY
diff --git a/gcc-4.9/libstdc++-v3/include/std/atomic b/gcc-4.9/libstdc++-v3/include/std/atomic
new file mode 100644
index 0000000..ece75a4
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/atomic
@@ -0,0 +1,1126 @@
+// -*- C++ -*- header.
+
+// Copyright (C) 2008-2014 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/atomic
+ * This is a Standard C++ Library header.
+ */
+
+// Based on "C++ Atomic Types and Operations" by Hans Boehm and Lawrence Crowl.
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html
+
+#ifndef _GLIBCXX_ATOMIC
+#define _GLIBCXX_ATOMIC 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#endif
+
+#include <bits/atomic_base.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @addtogroup atomics
+ * @{
+ */
+
+ /// atomic_bool
+ // NB: No operators or fetch-operations for this type.
+ struct atomic_bool
+ {
+ private:
+ __atomic_base<bool> _M_base;
+
+ public:
+ atomic_bool() noexcept = default;
+ ~atomic_bool() noexcept = default;
+ atomic_bool(const atomic_bool&) = delete;
+ atomic_bool& operator=(const atomic_bool&) = delete;
+ atomic_bool& operator=(const atomic_bool&) volatile = delete;
+
+ constexpr atomic_bool(bool __i) noexcept : _M_base(__i) { }
+
+ bool
+ operator=(bool __i) noexcept
+ { return _M_base.operator=(__i); }
+
+ bool
+ operator=(bool __i) volatile noexcept
+ { return _M_base.operator=(__i); }
+
+ operator bool() const noexcept
+ { return _M_base.load(); }
+
+ operator bool() const volatile noexcept
+ { return _M_base.load(); }
+
+ bool
+ is_lock_free() const noexcept { return _M_base.is_lock_free(); }
+
+ bool
+ is_lock_free() const volatile noexcept { return _M_base.is_lock_free(); }
+
+ void
+ store(bool __i, memory_order __m = memory_order_seq_cst) noexcept
+ { _M_base.store(__i, __m); }
+
+ void
+ store(bool __i, memory_order __m = memory_order_seq_cst) volatile noexcept
+ { _M_base.store(__i, __m); }
+
+ bool
+ load(memory_order __m = memory_order_seq_cst) const noexcept
+ { return _M_base.load(__m); }
+
+ bool
+ load(memory_order __m = memory_order_seq_cst) const volatile noexcept
+ { return _M_base.load(__m); }
+
+ bool
+ exchange(bool __i, memory_order __m = memory_order_seq_cst) noexcept
+ { return _M_base.exchange(__i, __m); }
+
+ bool
+ exchange(bool __i,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ { return _M_base.exchange(__i, __m); }
+
+ bool
+ compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
+ memory_order __m2) noexcept
+ { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
+
+ bool
+ compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
+ memory_order __m2) volatile noexcept
+ { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
+
+ bool
+ compare_exchange_weak(bool& __i1, bool __i2,
+ memory_order __m = memory_order_seq_cst) noexcept
+ { return _M_base.compare_exchange_weak(__i1, __i2, __m); }
+
+ bool
+ compare_exchange_weak(bool& __i1, bool __i2,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ { return _M_base.compare_exchange_weak(__i1, __i2, __m); }
+
+ bool
+ compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
+ memory_order __m2) noexcept
+ { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
+
+ bool
+ compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
+ memory_order __m2) volatile noexcept
+ { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
+
+ bool
+ compare_exchange_strong(bool& __i1, bool __i2,
+ memory_order __m = memory_order_seq_cst) noexcept
+ { return _M_base.compare_exchange_strong(__i1, __i2, __m); }
+
+ bool
+ compare_exchange_strong(bool& __i1, bool __i2,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ { return _M_base.compare_exchange_strong(__i1, __i2, __m); }
+ };
+
+
+ /**
+ * @brief Generic atomic type, primary class template.
+ *
+ * @tparam _Tp Type to be made atomic, must be trivally copyable.
+ */
+ template<typename _Tp>
+ struct atomic
+ {
+ private:
+ _Tp _M_i;
+
+ public:
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(_Tp __i) noexcept : _M_i(__i) { }
+
+ operator _Tp() const noexcept
+ { return load(); }
+
+ operator _Tp() const volatile noexcept
+ { return load(); }
+
+ _Tp
+ operator=(_Tp __i) noexcept
+ { store(__i); return __i; }
+
+ _Tp
+ operator=(_Tp __i) volatile noexcept
+ { store(__i); return __i; }
+
+ bool
+ is_lock_free() const noexcept
+ { return __atomic_is_lock_free(sizeof(_M_i), nullptr); }
+
+ bool
+ is_lock_free() const volatile noexcept
+ { return __atomic_is_lock_free(sizeof(_M_i), nullptr); }
+
+ void
+ store(_Tp __i, memory_order _m = memory_order_seq_cst) noexcept
+ { __atomic_store(&_M_i, &__i, _m); }
+
+ void
+ store(_Tp __i, memory_order _m = memory_order_seq_cst) volatile noexcept
+ { __atomic_store(&_M_i, &__i, _m); }
+
+ _Tp
+ load(memory_order _m = memory_order_seq_cst) const noexcept
+ {
+ _Tp tmp;
+ __atomic_load(&_M_i, &tmp, _m);
+ return tmp;
+ }
+
+ _Tp
+ load(memory_order _m = memory_order_seq_cst) const volatile noexcept
+ {
+ _Tp tmp;
+ __atomic_load(&_M_i, &tmp, _m);
+ return tmp;
+ }
+
+ _Tp
+ exchange(_Tp __i, memory_order _m = memory_order_seq_cst) noexcept
+ {
+ _Tp tmp;
+ __atomic_exchange(&_M_i, &__i, &tmp, _m);
+ return tmp;
+ }
+
+ _Tp
+ exchange(_Tp __i,
+ memory_order _m = memory_order_seq_cst) volatile noexcept
+ {
+ _Tp tmp;
+ __atomic_exchange(&_M_i, &__i, &tmp, _m);
+ return tmp;
+ }
+
+ bool
+ compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s,
+ memory_order __f) noexcept
+ {
+ return __atomic_compare_exchange(&_M_i, &__e, &__i, true, __s, __f);
+ }
+
+ bool
+ compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s,
+ memory_order __f) volatile noexcept
+ {
+ return __atomic_compare_exchange(&_M_i, &__e, &__i, true, __s, __f);
+ }
+
+ bool
+ compare_exchange_weak(_Tp& __e, _Tp __i,
+ memory_order __m = memory_order_seq_cst) noexcept
+ { return compare_exchange_weak(__e, __i, __m,
+ __cmpexch_failure_order(__m)); }
+
+ bool
+ compare_exchange_weak(_Tp& __e, _Tp __i,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ { return compare_exchange_weak(__e, __i, __m,
+ __cmpexch_failure_order(__m)); }
+
+ bool
+ compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s,
+ memory_order __f) noexcept
+ {
+ return __atomic_compare_exchange(&_M_i, &__e, &__i, false, __s, __f);
+ }
+
+ bool
+ compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s,
+ memory_order __f) volatile noexcept
+ {
+ return __atomic_compare_exchange(&_M_i, &__e, &__i, false, __s, __f);
+ }
+
+ bool
+ compare_exchange_strong(_Tp& __e, _Tp __i,
+ memory_order __m = memory_order_seq_cst) noexcept
+ { return compare_exchange_strong(__e, __i, __m,
+ __cmpexch_failure_order(__m)); }
+
+ bool
+ compare_exchange_strong(_Tp& __e, _Tp __i,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ { return compare_exchange_strong(__e, __i, __m,
+ __cmpexch_failure_order(__m)); }
+ };
+
+
+ /// Partial specialization for pointer types.
+ template<typename _Tp>
+ struct atomic<_Tp*>
+ {
+ typedef _Tp* __pointer_type;
+ typedef __atomic_base<_Tp*> __base_type;
+ __base_type _M_b;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__pointer_type __p) noexcept : _M_b(__p) { }
+
+ operator __pointer_type() const noexcept
+ { return __pointer_type(_M_b); }
+
+ operator __pointer_type() const volatile noexcept
+ { return __pointer_type(_M_b); }
+
+ __pointer_type
+ operator=(__pointer_type __p) noexcept
+ { return _M_b.operator=(__p); }
+
+ __pointer_type
+ operator=(__pointer_type __p) volatile noexcept
+ { return _M_b.operator=(__p); }
+
+ __pointer_type
+ operator++(int) noexcept
+ { return _M_b++; }
+
+ __pointer_type
+ operator++(int) volatile noexcept
+ { return _M_b++; }
+
+ __pointer_type
+ operator--(int) noexcept
+ { return _M_b--; }
+
+ __pointer_type
+ operator--(int) volatile noexcept
+ { return _M_b--; }
+
+ __pointer_type
+ operator++() noexcept
+ { return ++_M_b; }
+
+ __pointer_type
+ operator++() volatile noexcept
+ { return ++_M_b; }
+
+ __pointer_type
+ operator--() noexcept
+ { return --_M_b; }
+
+ __pointer_type
+ operator--() volatile noexcept
+ { return --_M_b; }
+
+ __pointer_type
+ operator+=(ptrdiff_t __d) noexcept
+ { return _M_b.operator+=(__d); }
+
+ __pointer_type
+ operator+=(ptrdiff_t __d) volatile noexcept
+ { return _M_b.operator+=(__d); }
+
+ __pointer_type
+ operator-=(ptrdiff_t __d) noexcept
+ { return _M_b.operator-=(__d); }
+
+ __pointer_type
+ operator-=(ptrdiff_t __d) volatile noexcept
+ { return _M_b.operator-=(__d); }
+
+ bool
+ is_lock_free() const noexcept
+ { return _M_b.is_lock_free(); }
+
+ bool
+ is_lock_free() const volatile noexcept
+ { return _M_b.is_lock_free(); }
+
+ void
+ store(__pointer_type __p,
+ memory_order __m = memory_order_seq_cst) noexcept
+ { return _M_b.store(__p, __m); }
+
+ void
+ store(__pointer_type __p,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ { return _M_b.store(__p, __m); }
+
+ __pointer_type
+ load(memory_order __m = memory_order_seq_cst) const noexcept
+ { return _M_b.load(__m); }
+
+ __pointer_type
+ load(memory_order __m = memory_order_seq_cst) const volatile noexcept
+ { return _M_b.load(__m); }
+
+ __pointer_type
+ exchange(__pointer_type __p,
+ memory_order __m = memory_order_seq_cst) noexcept
+ { return _M_b.exchange(__p, __m); }
+
+ __pointer_type
+ exchange(__pointer_type __p,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ { return _M_b.exchange(__p, __m); }
+
+ bool
+ compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
+ memory_order __m1, memory_order __m2) noexcept
+ { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
+
+ bool
+ compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
+ memory_order __m1,
+ memory_order __m2) volatile noexcept
+ { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
+
+ bool
+ compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
+ memory_order __m = memory_order_seq_cst) noexcept
+ {
+ return compare_exchange_weak(__p1, __p2, __m,
+ __cmpexch_failure_order(__m));
+ }
+
+ bool
+ compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ {
+ return compare_exchange_weak(__p1, __p2, __m,
+ __cmpexch_failure_order(__m));
+ }
+
+ bool
+ compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
+ memory_order __m1, memory_order __m2) noexcept
+ { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
+
+ bool
+ compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
+ memory_order __m1,
+ memory_order __m2) volatile noexcept
+ { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
+
+ bool
+ compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
+ memory_order __m = memory_order_seq_cst) noexcept
+ {
+ return _M_b.compare_exchange_strong(__p1, __p2, __m,
+ __cmpexch_failure_order(__m));
+ }
+
+ bool
+ compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ {
+ return _M_b.compare_exchange_strong(__p1, __p2, __m,
+ __cmpexch_failure_order(__m));
+ }
+
+ __pointer_type
+ fetch_add(ptrdiff_t __d,
+ memory_order __m = memory_order_seq_cst) noexcept
+ { return _M_b.fetch_add(__d, __m); }
+
+ __pointer_type
+ fetch_add(ptrdiff_t __d,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ { return _M_b.fetch_add(__d, __m); }
+
+ __pointer_type
+ fetch_sub(ptrdiff_t __d,
+ memory_order __m = memory_order_seq_cst) noexcept
+ { return _M_b.fetch_sub(__d, __m); }
+
+ __pointer_type
+ fetch_sub(ptrdiff_t __d,
+ memory_order __m = memory_order_seq_cst) volatile noexcept
+ { return _M_b.fetch_sub(__d, __m); }
+ };
+
+
+ /// Explicit specialization for bool.
+ template<>
+ struct atomic<bool> : public atomic_bool
+ {
+ typedef bool __integral_type;
+ typedef atomic_bool __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for char.
+ template<>
+ struct atomic<char> : public atomic_char
+ {
+ typedef char __integral_type;
+ typedef atomic_char __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for signed char.
+ template<>
+ struct atomic<signed char> : public atomic_schar
+ {
+ typedef signed char __integral_type;
+ typedef atomic_schar __base_type;
+
+ atomic() noexcept= default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for unsigned char.
+ template<>
+ struct atomic<unsigned char> : public atomic_uchar
+ {
+ typedef unsigned char __integral_type;
+ typedef atomic_uchar __base_type;
+
+ atomic() noexcept= default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for short.
+ template<>
+ struct atomic<short> : public atomic_short
+ {
+ typedef short __integral_type;
+ typedef atomic_short __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for unsigned short.
+ template<>
+ struct atomic<unsigned short> : public atomic_ushort
+ {
+ typedef unsigned short __integral_type;
+ typedef atomic_ushort __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for int.
+ template<>
+ struct atomic<int> : atomic_int
+ {
+ typedef int __integral_type;
+ typedef atomic_int __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for unsigned int.
+ template<>
+ struct atomic<unsigned int> : public atomic_uint
+ {
+ typedef unsigned int __integral_type;
+ typedef atomic_uint __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for long.
+ template<>
+ struct atomic<long> : public atomic_long
+ {
+ typedef long __integral_type;
+ typedef atomic_long __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for unsigned long.
+ template<>
+ struct atomic<unsigned long> : public atomic_ulong
+ {
+ typedef unsigned long __integral_type;
+ typedef atomic_ulong __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for long long.
+ template<>
+ struct atomic<long long> : public atomic_llong
+ {
+ typedef long long __integral_type;
+ typedef atomic_llong __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for unsigned long long.
+ template<>
+ struct atomic<unsigned long long> : public atomic_ullong
+ {
+ typedef unsigned long long __integral_type;
+ typedef atomic_ullong __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for wchar_t.
+ template<>
+ struct atomic<wchar_t> : public atomic_wchar_t
+ {
+ typedef wchar_t __integral_type;
+ typedef atomic_wchar_t __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for char16_t.
+ template<>
+ struct atomic<char16_t> : public atomic_char16_t
+ {
+ typedef char16_t __integral_type;
+ typedef atomic_char16_t __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+ /// Explicit specialization for char32_t.
+ template<>
+ struct atomic<char32_t> : public atomic_char32_t
+ {
+ typedef char32_t __integral_type;
+ typedef atomic_char32_t __base_type;
+
+ atomic() noexcept = default;
+ ~atomic() noexcept = default;
+ atomic(const atomic&) = delete;
+ atomic& operator=(const atomic&) = delete;
+ atomic& operator=(const atomic&) volatile = delete;
+
+ constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
+
+ using __base_type::operator __integral_type;
+ using __base_type::operator=;
+ };
+
+
+ // Function definitions, atomic_flag operations.
+ inline bool
+ atomic_flag_test_and_set_explicit(atomic_flag* __a,
+ memory_order __m) noexcept
+ { return __a->test_and_set(__m); }
+
+ inline bool
+ atomic_flag_test_and_set_explicit(volatile atomic_flag* __a,
+ memory_order __m) noexcept
+ { return __a->test_and_set(__m); }
+
+ inline void
+ atomic_flag_clear_explicit(atomic_flag* __a, memory_order __m) noexcept
+ { __a->clear(__m); }
+
+ inline void
+ atomic_flag_clear_explicit(volatile atomic_flag* __a,
+ memory_order __m) noexcept
+ { __a->clear(__m); }
+
+ inline bool
+ atomic_flag_test_and_set(atomic_flag* __a) noexcept
+ { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
+
+ inline bool
+ atomic_flag_test_and_set(volatile atomic_flag* __a) noexcept
+ { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
+
+ inline void
+ atomic_flag_clear(atomic_flag* __a) noexcept
+ { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
+
+ inline void
+ atomic_flag_clear(volatile atomic_flag* __a) noexcept
+ { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
+
+
+ // Function templates generally applicable to atomic types.
+ template<typename _ITp>
+ inline bool
+ atomic_is_lock_free(const atomic<_ITp>* __a) noexcept
+ { return __a->is_lock_free(); }
+
+ template<typename _ITp>
+ inline bool
+ atomic_is_lock_free(const volatile atomic<_ITp>* __a) noexcept
+ { return __a->is_lock_free(); }
+
+ template<typename _ITp>
+ inline void
+ atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept;
+
+ template<typename _ITp>
+ inline void
+ atomic_init(volatile atomic<_ITp>* __a, _ITp __i) noexcept;
+
+ template<typename _ITp>
+ inline void
+ atomic_store_explicit(atomic<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { __a->store(__i, __m); }
+
+ template<typename _ITp>
+ inline void
+ atomic_store_explicit(volatile atomic<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { __a->store(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_load_explicit(const atomic<_ITp>* __a, memory_order __m) noexcept
+ { return __a->load(__m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_load_explicit(const volatile atomic<_ITp>* __a,
+ memory_order __m) noexcept
+ { return __a->load(__m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_exchange_explicit(atomic<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->exchange(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_exchange_explicit(volatile atomic<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->exchange(__i, __m); }
+
+ template<typename _ITp>
+ inline bool
+ atomic_compare_exchange_weak_explicit(atomic<_ITp>* __a,
+ _ITp* __i1, _ITp __i2,
+ memory_order __m1,
+ memory_order __m2) noexcept
+ { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
+
+ template<typename _ITp>
+ inline bool
+ atomic_compare_exchange_weak_explicit(volatile atomic<_ITp>* __a,
+ _ITp* __i1, _ITp __i2,
+ memory_order __m1,
+ memory_order __m2) noexcept
+ { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
+
+ template<typename _ITp>
+ inline bool
+ atomic_compare_exchange_strong_explicit(atomic<_ITp>* __a,
+ _ITp* __i1, _ITp __i2,
+ memory_order __m1,
+ memory_order __m2) noexcept
+ { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
+
+ template<typename _ITp>
+ inline bool
+ atomic_compare_exchange_strong_explicit(volatile atomic<_ITp>* __a,
+ _ITp* __i1, _ITp __i2,
+ memory_order __m1,
+ memory_order __m2) noexcept
+ { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
+
+
+ template<typename _ITp>
+ inline void
+ atomic_store(atomic<_ITp>* __a, _ITp __i) noexcept
+ { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline void
+ atomic_store(volatile atomic<_ITp>* __a, _ITp __i) noexcept
+ { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_load(const atomic<_ITp>* __a) noexcept
+ { return atomic_load_explicit(__a, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_load(const volatile atomic<_ITp>* __a) noexcept
+ { return atomic_load_explicit(__a, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_exchange(atomic<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_exchange(volatile atomic<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline bool
+ atomic_compare_exchange_weak(atomic<_ITp>* __a,
+ _ITp* __i1, _ITp __i2) noexcept
+ {
+ return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
+ memory_order_seq_cst,
+ memory_order_seq_cst);
+ }
+
+ template<typename _ITp>
+ inline bool
+ atomic_compare_exchange_weak(volatile atomic<_ITp>* __a,
+ _ITp* __i1, _ITp __i2) noexcept
+ {
+ return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
+ memory_order_seq_cst,
+ memory_order_seq_cst);
+ }
+
+ template<typename _ITp>
+ inline bool
+ atomic_compare_exchange_strong(atomic<_ITp>* __a,
+ _ITp* __i1, _ITp __i2) noexcept
+ {
+ return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
+ memory_order_seq_cst,
+ memory_order_seq_cst);
+ }
+
+ template<typename _ITp>
+ inline bool
+ atomic_compare_exchange_strong(volatile atomic<_ITp>* __a,
+ _ITp* __i1, _ITp __i2) noexcept
+ {
+ return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
+ memory_order_seq_cst,
+ memory_order_seq_cst);
+ }
+
+ // Function templates for atomic_integral operations only, using
+ // __atomic_base. Template argument should be constricted to
+ // intergral types as specified in the standard, excluding address
+ // types.
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_add_explicit(__atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_add(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_add_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_add(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_sub_explicit(__atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_sub(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_sub_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_sub(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_and_explicit(__atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_and(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_and_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_and(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_or_explicit(__atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_or(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_or_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_or(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_xor(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_xor_explicit(volatile __atomic_base<_ITp>* __a, _ITp __i,
+ memory_order __m) noexcept
+ { return __a->fetch_xor(__i, __m); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_add(__atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_add(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_sub(__atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_sub(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_and(__atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_and(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_or(__atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_or(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_xor(__atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
+
+ template<typename _ITp>
+ inline _ITp
+ atomic_fetch_xor(volatile __atomic_base<_ITp>* __a, _ITp __i) noexcept
+ { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
+
+
+ // Partial specializations for pointers.
+ template<typename _ITp>
+ inline _ITp*
+ atomic_fetch_add_explicit(atomic<_ITp*>* __a, ptrdiff_t __d,
+ memory_order __m) noexcept
+ { return __a->fetch_add(__d, __m); }
+
+ template<typename _ITp>
+ inline _ITp*
+ atomic_fetch_add_explicit(volatile atomic<_ITp*>* __a, ptrdiff_t __d,
+ memory_order __m) noexcept
+ { return __a->fetch_add(__d, __m); }
+
+ template<typename _ITp>
+ inline _ITp*
+ atomic_fetch_add(volatile atomic<_ITp*>* __a, ptrdiff_t __d) noexcept
+ { return __a->fetch_add(__d); }
+
+ template<typename _ITp>
+ inline _ITp*
+ atomic_fetch_add(atomic<_ITp*>* __a, ptrdiff_t __d) noexcept
+ { return __a->fetch_add(__d); }
+
+ template<typename _ITp>
+ inline _ITp*
+ atomic_fetch_sub_explicit(volatile atomic<_ITp*>* __a,
+ ptrdiff_t __d, memory_order __m) noexcept
+ { return __a->fetch_sub(__d, __m); }
+
+ template<typename _ITp>
+ inline _ITp*
+ atomic_fetch_sub_explicit(atomic<_ITp*>* __a, ptrdiff_t __d,
+ memory_order __m) noexcept
+ { return __a->fetch_sub(__d, __m); }
+
+ template<typename _ITp>
+ inline _ITp*
+ atomic_fetch_sub(volatile atomic<_ITp*>* __a, ptrdiff_t __d) noexcept
+ { return __a->fetch_sub(__d); }
+
+ template<typename _ITp>
+ inline _ITp*
+ atomic_fetch_sub(atomic<_ITp*>* __a, ptrdiff_t __d) noexcept
+ { return __a->fetch_sub(__d); }
+ // @} group atomics
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif
diff --git a/gcc-4.9/libstdc++-v3/include/std/bitset b/gcc-4.9/libstdc++-v3/include/std/bitset
new file mode 100644
index 0000000..d9d4f4d
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/bitset
@@ -0,0 +1,1595 @@
+// <bitset> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ * Copyright (c) 1998
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/bitset
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_BITSET
+#define _GLIBCXX_BITSET 1
+
+#pragma GCC system_header
+
+#include <string>
+#include <bits/functexcept.h> // For invalid_argument, out_of_range,
+ // overflow_error
+#include <iosfwd>
+#include <bits/cxxabi_forced.h>
+
+#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * __SIZEOF_LONG__)
+#define _GLIBCXX_BITSET_WORDS(__n) \
+ ((__n) / _GLIBCXX_BITSET_BITS_PER_WORD + \
+ ((__n) % _GLIBCXX_BITSET_BITS_PER_WORD == 0 ? 0 : 1))
+
+#define _GLIBCXX_BITSET_BITS_PER_ULL (__CHAR_BIT__ * __SIZEOF_LONG_LONG__)
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
+
+ /**
+ * Base class, general case. It is a class invariant that _Nw will be
+ * nonnegative.
+ *
+ * See documentation for bitset.
+ */
+ template<size_t _Nw>
+ struct _Base_bitset
+ {
+ typedef unsigned long _WordT;
+
+ /// 0 is the least significant word.
+ _WordT _M_w[_Nw];
+
+ _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT
+ : _M_w() { }
+
+#if __cplusplus >= 201103L
+ constexpr _Base_bitset(unsigned long long __val) noexcept
+ : _M_w{ _WordT(__val)
+#if __SIZEOF_LONG_LONG__ > __SIZEOF_LONG__
+ , _WordT(__val >> _GLIBCXX_BITSET_BITS_PER_WORD)
+#endif
+ } { }
+#else
+ _Base_bitset(unsigned long __val)
+ : _M_w()
+ { _M_w[0] = __val; }
+#endif
+
+ static _GLIBCXX_CONSTEXPR size_t
+ _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; }
+
+ static _GLIBCXX_CONSTEXPR size_t
+ _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; }
+
+ static _GLIBCXX_CONSTEXPR size_t
+ _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; }
+
+ static _GLIBCXX_CONSTEXPR _WordT
+ _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }
+
+ _WordT&
+ _M_getword(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return _M_w[_S_whichword(__pos)]; }
+
+ _GLIBCXX_CONSTEXPR _WordT
+ _M_getword(size_t __pos) const _GLIBCXX_NOEXCEPT
+ { return _M_w[_S_whichword(__pos)]; }
+
+#if __cplusplus >= 201103L
+ const _WordT*
+ _M_getdata() const noexcept
+ { return _M_w; }
+#endif
+
+ _WordT&
+ _M_hiword() _GLIBCXX_NOEXCEPT
+ { return _M_w[_Nw - 1]; }
+
+ _GLIBCXX_CONSTEXPR _WordT
+ _M_hiword() const _GLIBCXX_NOEXCEPT
+ { return _M_w[_Nw - 1]; }
+
+ void
+ _M_do_and(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw; __i++)
+ _M_w[__i] &= __x._M_w[__i];
+ }
+
+ void
+ _M_do_or(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw; __i++)
+ _M_w[__i] |= __x._M_w[__i];
+ }
+
+ void
+ _M_do_xor(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw; __i++)
+ _M_w[__i] ^= __x._M_w[__i];
+ }
+
+ void
+ _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT;
+
+ void
+ _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT;
+
+ void
+ _M_do_flip() _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw; __i++)
+ _M_w[__i] = ~_M_w[__i];
+ }
+
+ void
+ _M_do_set() _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw; __i++)
+ _M_w[__i] = ~static_cast<_WordT>(0);
+ }
+
+ void
+ _M_do_reset() _GLIBCXX_NOEXCEPT
+ { __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); }
+
+ bool
+ _M_is_equal(const _Base_bitset<_Nw>& __x) const _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw; ++__i)
+ if (_M_w[__i] != __x._M_w[__i])
+ return false;
+ return true;
+ }
+
+ template<size_t _Nb>
+ bool
+ _M_are_all() const _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw - 1; __i++)
+ if (_M_w[__i] != ~static_cast<_WordT>(0))
+ return false;
+ return _M_hiword() == (~static_cast<_WordT>(0)
+ >> (_Nw * _GLIBCXX_BITSET_BITS_PER_WORD
+ - _Nb));
+ }
+
+ bool
+ _M_is_any() const _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw; __i++)
+ if (_M_w[__i] != static_cast<_WordT>(0))
+ return true;
+ return false;
+ }
+
+ size_t
+ _M_do_count() const _GLIBCXX_NOEXCEPT
+ {
+ size_t __result = 0;
+ for (size_t __i = 0; __i < _Nw; __i++)
+ __result += __builtin_popcountl(_M_w[__i]);
+ return __result;
+ }
+
+ unsigned long
+ _M_do_to_ulong() const;
+
+#if __cplusplus >= 201103L
+ unsigned long long
+ _M_do_to_ullong() const;
+#endif
+
+ // find first "on" bit
+ size_t
+ _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT;
+
+ // find the next "on" bit that follows "prev"
+ size_t
+ _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT;
+ };
+
+ // Definitions of non-inline functions from _Base_bitset.
+ template<size_t _Nw>
+ void
+ _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT
+ {
+ if (__builtin_expect(__shift != 0, 1))
+ {
+ const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD;
+ const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD;
+
+ if (__offset == 0)
+ for (size_t __n = _Nw - 1; __n >= __wshift; --__n)
+ _M_w[__n] = _M_w[__n - __wshift];
+ else
+ {
+ const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD
+ - __offset);
+ for (size_t __n = _Nw - 1; __n > __wshift; --__n)
+ _M_w[__n] = ((_M_w[__n - __wshift] << __offset)
+ | (_M_w[__n - __wshift - 1] >> __sub_offset));
+ _M_w[__wshift] = _M_w[0] << __offset;
+ }
+
+ std::fill(_M_w + 0, _M_w + __wshift, static_cast<_WordT>(0));
+ }
+ }
+
+ template<size_t _Nw>
+ void
+ _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT
+ {
+ if (__builtin_expect(__shift != 0, 1))
+ {
+ const size_t __wshift = __shift / _GLIBCXX_BITSET_BITS_PER_WORD;
+ const size_t __offset = __shift % _GLIBCXX_BITSET_BITS_PER_WORD;
+ const size_t __limit = _Nw - __wshift - 1;
+
+ if (__offset == 0)
+ for (size_t __n = 0; __n <= __limit; ++__n)
+ _M_w[__n] = _M_w[__n + __wshift];
+ else
+ {
+ const size_t __sub_offset = (_GLIBCXX_BITSET_BITS_PER_WORD
+ - __offset);
+ for (size_t __n = 0; __n < __limit; ++__n)
+ _M_w[__n] = ((_M_w[__n + __wshift] >> __offset)
+ | (_M_w[__n + __wshift + 1] << __sub_offset));
+ _M_w[__limit] = _M_w[_Nw-1] >> __offset;
+ }
+
+ std::fill(_M_w + __limit + 1, _M_w + _Nw, static_cast<_WordT>(0));
+ }
+ }
+
+ template<size_t _Nw>
+ unsigned long
+ _Base_bitset<_Nw>::_M_do_to_ulong() const
+ {
+ for (size_t __i = 1; __i < _Nw; ++__i)
+ if (_M_w[__i])
+ __throw_overflow_error(__N("_Base_bitset::_M_do_to_ulong"));
+ return _M_w[0];
+ }
+
+#if __cplusplus >= 201103L
+ template<size_t _Nw>
+ unsigned long long
+ _Base_bitset<_Nw>::_M_do_to_ullong() const
+ {
+ const bool __dw = sizeof(unsigned long long) > sizeof(unsigned long);
+ for (size_t __i = 1 + __dw; __i < _Nw; ++__i)
+ if (_M_w[__i])
+ __throw_overflow_error(__N("_Base_bitset::_M_do_to_ullong"));
+
+ if (__dw)
+ return _M_w[0] + (static_cast<unsigned long long>(_M_w[1])
+ << _GLIBCXX_BITSET_BITS_PER_WORD);
+ return _M_w[0];
+ }
+#endif
+
+ template<size_t _Nw>
+ size_t
+ _Base_bitset<_Nw>::
+ _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT
+ {
+ for (size_t __i = 0; __i < _Nw; __i++)
+ {
+ _WordT __thisword = _M_w[__i];
+ if (__thisword != static_cast<_WordT>(0))
+ return (__i * _GLIBCXX_BITSET_BITS_PER_WORD
+ + __builtin_ctzl(__thisword));
+ }
+ // not found, so return an indication of failure.
+ return __not_found;
+ }
+
+ template<size_t _Nw>
+ size_t
+ _Base_bitset<_Nw>::
+ _M_do_find_next(size_t __prev, size_t __not_found) const _GLIBCXX_NOEXCEPT
+ {
+ // make bound inclusive
+ ++__prev;
+
+ // check out of bounds
+ if (__prev >= _Nw * _GLIBCXX_BITSET_BITS_PER_WORD)
+ return __not_found;
+
+ // search first word
+ size_t __i = _S_whichword(__prev);
+ _WordT __thisword = _M_w[__i];
+
+ // mask off bits below bound
+ __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev);
+
+ if (__thisword != static_cast<_WordT>(0))
+ return (__i * _GLIBCXX_BITSET_BITS_PER_WORD
+ + __builtin_ctzl(__thisword));
+
+ // check subsequent words
+ __i++;
+ for (; __i < _Nw; __i++)
+ {
+ __thisword = _M_w[__i];
+ if (__thisword != static_cast<_WordT>(0))
+ return (__i * _GLIBCXX_BITSET_BITS_PER_WORD
+ + __builtin_ctzl(__thisword));
+ }
+ // not found, so return an indication of failure.
+ return __not_found;
+ } // end _M_do_find_next
+
+ /**
+ * Base class, specialization for a single word.
+ *
+ * See documentation for bitset.
+ */
+ template<>
+ struct _Base_bitset<1>
+ {
+ typedef unsigned long _WordT;
+ _WordT _M_w;
+
+ _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT
+ : _M_w(0)
+ { }
+
+#if __cplusplus >= 201103L
+ constexpr _Base_bitset(unsigned long long __val) noexcept
+#else
+ _Base_bitset(unsigned long __val)
+#endif
+ : _M_w(__val)
+ { }
+
+ static _GLIBCXX_CONSTEXPR size_t
+ _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; }
+
+ static _GLIBCXX_CONSTEXPR size_t
+ _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; }
+
+ static _GLIBCXX_CONSTEXPR size_t
+ _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; }
+
+ static _GLIBCXX_CONSTEXPR _WordT
+ _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }
+
+ _WordT&
+ _M_getword(size_t) _GLIBCXX_NOEXCEPT
+ { return _M_w; }
+
+ _GLIBCXX_CONSTEXPR _WordT
+ _M_getword(size_t) const _GLIBCXX_NOEXCEPT
+ { return _M_w; }
+
+#if __cplusplus >= 201103L
+ const _WordT*
+ _M_getdata() const noexcept
+ { return &_M_w; }
+#endif
+
+ _WordT&
+ _M_hiword() _GLIBCXX_NOEXCEPT
+ { return _M_w; }
+
+ _GLIBCXX_CONSTEXPR _WordT
+ _M_hiword() const _GLIBCXX_NOEXCEPT
+ { return _M_w; }
+
+ void
+ _M_do_and(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT
+ { _M_w &= __x._M_w; }
+
+ void
+ _M_do_or(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT
+ { _M_w |= __x._M_w; }
+
+ void
+ _M_do_xor(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT
+ { _M_w ^= __x._M_w; }
+
+ void
+ _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT
+ { _M_w <<= __shift; }
+
+ void
+ _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT
+ { _M_w >>= __shift; }
+
+ void
+ _M_do_flip() _GLIBCXX_NOEXCEPT
+ { _M_w = ~_M_w; }
+
+ void
+ _M_do_set() _GLIBCXX_NOEXCEPT
+ { _M_w = ~static_cast<_WordT>(0); }
+
+ void
+ _M_do_reset() _GLIBCXX_NOEXCEPT
+ { _M_w = 0; }
+
+ bool
+ _M_is_equal(const _Base_bitset<1>& __x) const _GLIBCXX_NOEXCEPT
+ { return _M_w == __x._M_w; }
+
+ template<size_t _Nb>
+ bool
+ _M_are_all() const _GLIBCXX_NOEXCEPT
+ { return _M_w == (~static_cast<_WordT>(0)
+ >> (_GLIBCXX_BITSET_BITS_PER_WORD - _Nb)); }
+
+ bool
+ _M_is_any() const _GLIBCXX_NOEXCEPT
+ { return _M_w != 0; }
+
+ size_t
+ _M_do_count() const _GLIBCXX_NOEXCEPT
+ { return __builtin_popcountl(_M_w); }
+
+ unsigned long
+ _M_do_to_ulong() const _GLIBCXX_NOEXCEPT
+ { return _M_w; }
+
+#if __cplusplus >= 201103L
+ unsigned long long
+ _M_do_to_ullong() const noexcept
+ { return _M_w; }
+#endif
+
+ size_t
+ _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT
+ {
+ if (_M_w != 0)
+ return __builtin_ctzl(_M_w);
+ else
+ return __not_found;
+ }
+
+ // find the next "on" bit that follows "prev"
+ size_t
+ _M_do_find_next(size_t __prev, size_t __not_found) const
+ _GLIBCXX_NOEXCEPT
+ {
+ ++__prev;
+ if (__prev >= ((size_t) _GLIBCXX_BITSET_BITS_PER_WORD))
+ return __not_found;
+
+ _WordT __x = _M_w >> __prev;
+ if (__x != 0)
+ return __builtin_ctzl(__x) + __prev;
+ else
+ return __not_found;
+ }
+ };
+
+ /**
+ * Base class, specialization for no storage (zero-length %bitset).
+ *
+ * See documentation for bitset.
+ */
+ template<>
+ struct _Base_bitset<0>
+ {
+ typedef unsigned long _WordT;
+
+ _GLIBCXX_CONSTEXPR _Base_bitset() _GLIBCXX_NOEXCEPT
+ { }
+
+#if __cplusplus >= 201103L
+ constexpr _Base_bitset(unsigned long long) noexcept
+#else
+ _Base_bitset(unsigned long)
+#endif
+ { }
+
+ static _GLIBCXX_CONSTEXPR size_t
+ _S_whichword(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return __pos / _GLIBCXX_BITSET_BITS_PER_WORD; }
+
+ static _GLIBCXX_CONSTEXPR size_t
+ _S_whichbyte(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return (__pos % _GLIBCXX_BITSET_BITS_PER_WORD) / __CHAR_BIT__; }
+
+ static _GLIBCXX_CONSTEXPR size_t
+ _S_whichbit(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return __pos % _GLIBCXX_BITSET_BITS_PER_WORD; }
+
+ static _GLIBCXX_CONSTEXPR _WordT
+ _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT
+ { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); }
+
+ // This would normally give access to the data. The bounds-checking
+ // in the bitset class will prevent the user from getting this far,
+ // but (1) it must still return an lvalue to compile, and (2) the
+ // user might call _Unchecked_set directly, in which case this /needs/
+ // to fail. Let's not penalize zero-length users unless they actually
+ // make an unchecked call; all the memory ugliness is therefore
+ // localized to this single should-never-get-this-far function.
+ _WordT&
+ _M_getword(size_t) _GLIBCXX_NOEXCEPT
+ {
+ __throw_out_of_range(__N("_Base_bitset::_M_getword"));
+ return *new _WordT;
+ }
+
+ _GLIBCXX_CONSTEXPR _WordT
+ _M_getword(size_t __pos) const _GLIBCXX_NOEXCEPT
+ { return 0; }
+
+ _GLIBCXX_CONSTEXPR _WordT
+ _M_hiword() const _GLIBCXX_NOEXCEPT
+ { return 0; }
+
+ void
+ _M_do_and(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT
+ { }
+
+ void
+ _M_do_or(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT
+ { }
+
+ void
+ _M_do_xor(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT
+ { }
+
+ void
+ _M_do_left_shift(size_t) _GLIBCXX_NOEXCEPT
+ { }
+
+ void
+ _M_do_right_shift(size_t) _GLIBCXX_NOEXCEPT
+ { }
+
+ void
+ _M_do_flip() _GLIBCXX_NOEXCEPT
+ { }
+
+ void
+ _M_do_set() _GLIBCXX_NOEXCEPT
+ { }
+
+ void
+ _M_do_reset() _GLIBCXX_NOEXCEPT
+ { }
+
+ // Are all empty bitsets equal to each other? Are they equal to
+ // themselves? How to compare a thing which has no state? What is
+ // the sound of one zero-length bitset clapping?
+ bool
+ _M_is_equal(const _Base_bitset<0>&) const _GLIBCXX_NOEXCEPT
+ { return true; }
+
+ template<size_t _Nb>
+ bool
+ _M_are_all() const _GLIBCXX_NOEXCEPT
+ { return true; }
+
+ bool
+ _M_is_any() const _GLIBCXX_NOEXCEPT
+ { return false; }
+
+ size_t
+ _M_do_count() const _GLIBCXX_NOEXCEPT
+ { return 0; }
+
+ unsigned long
+ _M_do_to_ulong() const _GLIBCXX_NOEXCEPT
+ { return 0; }
+
+#if __cplusplus >= 201103L
+ unsigned long long
+ _M_do_to_ullong() const noexcept
+ { return 0; }
+#endif
+
+ // Normally "not found" is the size, but that could also be
+ // misinterpreted as an index in this corner case. Oh well.
+ size_t
+ _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT
+ { return 0; }
+
+ size_t
+ _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT
+ { return 0; }
+ };
+
+
+ // Helper class to zero out the unused high-order bits in the highest word.
+ template<size_t _Extrabits>
+ struct _Sanitize
+ {
+ typedef unsigned long _WordT;
+
+ static void
+ _S_do_sanitize(_WordT& __val) _GLIBCXX_NOEXCEPT
+ { __val &= ~((~static_cast<_WordT>(0)) << _Extrabits); }
+ };
+
+ template<>
+ struct _Sanitize<0>
+ {
+ typedef unsigned long _WordT;
+
+ static void
+ _S_do_sanitize(_WordT) _GLIBCXX_NOEXCEPT { }
+ };
+
+#if __cplusplus >= 201103L
+ template<size_t _Nb, bool = _Nb < _GLIBCXX_BITSET_BITS_PER_ULL>
+ struct _Sanitize_val
+ {
+ static constexpr unsigned long long
+ _S_do_sanitize_val(unsigned long long __val)
+ { return __val; }
+ };
+
+ template<size_t _Nb>
+ struct _Sanitize_val<_Nb, true>
+ {
+ static constexpr unsigned long long
+ _S_do_sanitize_val(unsigned long long __val)
+ { return __val & ~((~static_cast<unsigned long long>(0)) << _Nb); }
+ };
+#endif
+
+ /**
+ * The %bitset class represents a @e fixed-size sequence of bits.
+ *
+ * @ingroup containers
+ *
+ * (Note that %bitset does @e not meet the formal requirements of a
+ * <a href="tables.html#65">container</a>. Mainly, it lacks iterators.)
+ *
+ * The template argument, @a Nb, may be any non-negative number,
+ * specifying the number of bits (e.g., "0", "12", "1024*1024").
+ *
+ * In the general unoptimized case, storage is allocated in word-sized
+ * blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B
+ * words will be used for storage. B - Nb%B bits are unused. (They are
+ * the high-order bits in the highest word.) It is a class invariant
+ * that those unused bits are always zero.
+ *
+ * If you think of %bitset as <em>a simple array of bits</em>, be
+ * aware that your mental picture is reversed: a %bitset behaves
+ * the same way as bits in integers do, with the bit at index 0 in
+ * the <em>least significant / right-hand</em> position, and the bit at
+ * index Nb-1 in the <em>most significant / left-hand</em> position.
+ * Thus, unlike other containers, a %bitset's index <em>counts from
+ * right to left</em>, to put it very loosely.
+ *
+ * This behavior is preserved when translating to and from strings. For
+ * example, the first line of the following program probably prints
+ * <em>b(&apos;a&apos;) is 0001100001</em> on a modern ASCII system.
+ *
+ * @code
+ * #include <bitset>
+ * #include <iostream>
+ * #include <sstream>
+ *
+ * using namespace std;
+ *
+ * int main()
+ * {
+ * long a = 'a';
+ * bitset<10> b(a);
+ *
+ * cout << "b('a') is " << b << endl;
+ *
+ * ostringstream s;
+ * s << b;
+ * string str = s.str();
+ * cout << "index 3 in the string is " << str[3] << " but\n"
+ * << "index 3 in the bitset is " << b[3] << endl;
+ * }
+ * @endcode
+ *
+ * Also see:
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch33s02.html
+ * for a description of extensions.
+ *
+ * Most of the actual code isn't contained in %bitset<> itself, but in the
+ * base class _Base_bitset. The base class works with whole words, not with
+ * individual bits. This allows us to specialize _Base_bitset for the
+ * important special case where the %bitset is only a single word.
+ *
+ * Extra confusion can result due to the fact that the storage for
+ * _Base_bitset @e is a regular array, and is indexed as such. This is
+ * carefully encapsulated.
+ */
+ template<size_t _Nb>
+ class bitset
+ : private _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)>
+ {
+ private:
+ typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base;
+ typedef unsigned long _WordT;
+
+ template<class _CharT, class _Traits, class _Alloc>
+ void
+ _M_check_initial_position(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
+ size_t __position) const
+ {
+ if (__position > __s.size())
+ __throw_out_of_range_fmt(__N("bitset::bitset: __position "
+ "(which is %zu) > __s.size() "
+ "(which is %zu)"),
+ __position, __s.size());
+ }
+
+ void _M_check(size_t __position, const char *__s) const
+ {
+ if (__position >= _Nb)
+ __throw_out_of_range_fmt(__N("%s: __position (which is %zu) "
+ ">= _Nb (which is %zu)"),
+ __s, __position, _Nb);
+ }
+
+ void
+ _M_do_sanitize() _GLIBCXX_NOEXCEPT
+ {
+ typedef _Sanitize<_Nb % _GLIBCXX_BITSET_BITS_PER_WORD> __sanitize_type;
+ __sanitize_type::_S_do_sanitize(this->_M_hiword());
+ }
+
+#if __cplusplus >= 201103L
+ template<typename> friend struct hash;
+#endif
+
+ public:
+ /**
+ * This encapsulates the concept of a single bit. An instance of this
+ * class is a proxy for an actual bit; this way the individual bit
+ * operations are done as faster word-size bitwise instructions.
+ *
+ * Most users will never need to use this class directly; conversions
+ * to and from bool are automatic and should be transparent. Overloaded
+ * operators help to preserve the illusion.
+ *
+ * (On a typical system, this <em>bit %reference</em> is 64
+ * times the size of an actual bit. Ha.)
+ */
+ class reference
+ {
+ friend class bitset;
+
+ _WordT* _M_wp;
+ size_t _M_bpos;
+
+ // left undefined
+ reference();
+
+ public:
+ reference(bitset& __b, size_t __pos) _GLIBCXX_NOEXCEPT
+ {
+ _M_wp = &__b._M_getword(__pos);
+ _M_bpos = _Base::_S_whichbit(__pos);
+ }
+
+ ~reference() _GLIBCXX_NOEXCEPT
+ { }
+
+ // For b[i] = __x;
+ reference&
+ operator=(bool __x) _GLIBCXX_NOEXCEPT
+ {
+ if (__x)
+ *_M_wp |= _Base::_S_maskbit(_M_bpos);
+ else
+ *_M_wp &= ~_Base::_S_maskbit(_M_bpos);
+ return *this;
+ }
+
+ // For b[i] = b[__j];
+ reference&
+ operator=(const reference& __j) _GLIBCXX_NOEXCEPT
+ {
+ if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos)))
+ *_M_wp |= _Base::_S_maskbit(_M_bpos);
+ else
+ *_M_wp &= ~_Base::_S_maskbit(_M_bpos);
+ return *this;
+ }
+
+ // Flips the bit
+ bool
+ operator~() const _GLIBCXX_NOEXCEPT
+ { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; }
+
+ // For __x = b[i];
+ operator bool() const _GLIBCXX_NOEXCEPT
+ { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; }
+
+ // For b[i].flip();
+ reference&
+ flip() _GLIBCXX_NOEXCEPT
+ {
+ *_M_wp ^= _Base::_S_maskbit(_M_bpos);
+ return *this;
+ }
+ };
+ friend class reference;
+
+ // 23.3.5.1 constructors:
+ /// All bits set to zero.
+ _GLIBCXX_CONSTEXPR bitset() _GLIBCXX_NOEXCEPT
+ { }
+
+ /// Initial bits bitwise-copied from a single word (others set to zero).
+#if __cplusplus >= 201103L
+ constexpr bitset(unsigned long long __val) noexcept
+ : _Base(_Sanitize_val<_Nb>::_S_do_sanitize_val(__val)) { }
+#else
+ bitset(unsigned long __val)
+ : _Base(__val)
+ { _M_do_sanitize(); }
+#endif
+
+ /**
+ * Use a subset of a string.
+ * @param __s A string of @a 0 and @a 1 characters.
+ * @param __position Index of the first character in @a __s to use;
+ * defaults to zero.
+ * @throw std::out_of_range If @a pos is bigger the size of @a __s.
+ * @throw std::invalid_argument If a character appears in the string
+ * which is neither @a 0 nor @a 1.
+ */
+ template<class _CharT, class _Traits, class _Alloc>
+ explicit
+ bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
+ size_t __position = 0)
+ : _Base()
+ {
+ _M_check_initial_position(__s, __position);
+ _M_copy_from_string(__s, __position,
+ std::basic_string<_CharT, _Traits, _Alloc>::npos,
+ _CharT('0'), _CharT('1'));
+ }
+
+ /**
+ * Use a subset of a string.
+ * @param __s A string of @a 0 and @a 1 characters.
+ * @param __position Index of the first character in @a __s to use.
+ * @param __n The number of characters to copy.
+ * @throw std::out_of_range If @a __position is bigger the size
+ * of @a __s.
+ * @throw std::invalid_argument If a character appears in the string
+ * which is neither @a 0 nor @a 1.
+ */
+ template<class _CharT, class _Traits, class _Alloc>
+ bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
+ size_t __position, size_t __n)
+ : _Base()
+ {
+ _M_check_initial_position(__s, __position);
+ _M_copy_from_string(__s, __position, __n, _CharT('0'), _CharT('1'));
+ }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 396. what are characters zero and one.
+ template<class _CharT, class _Traits, class _Alloc>
+ bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s,
+ size_t __position, size_t __n,
+ _CharT __zero, _CharT __one = _CharT('1'))
+ : _Base()
+ {
+ _M_check_initial_position(__s, __position);
+ _M_copy_from_string(__s, __position, __n, __zero, __one);
+ }
+
+#if __cplusplus >= 201103L
+ /**
+ * Construct from a character %array.
+ * @param __str An %array of characters @a zero and @a one.
+ * @param __n The number of characters to use.
+ * @param __zero The character corresponding to the value 0.
+ * @param __one The character corresponding to the value 1.
+ * @throw std::invalid_argument If a character appears in the string
+ * which is neither @a __zero nor @a __one.
+ */
+ template<typename _CharT>
+ explicit
+ bitset(const _CharT* __str,
+ typename std::basic_string<_CharT>::size_type __n
+ = std::basic_string<_CharT>::npos,
+ _CharT __zero = _CharT('0'), _CharT __one = _CharT('1'))
+ : _Base()
+ {
+ if (!__str)
+ __throw_logic_error(__N("bitset::bitset(const _CharT*, ...)"));
+
+ if (__n == std::basic_string<_CharT>::npos)
+ __n = std::char_traits<_CharT>::length(__str);
+ _M_copy_from_ptr<_CharT, std::char_traits<_CharT>>(__str, __n, 0,
+ __n, __zero,
+ __one);
+ }
+#endif
+
+ // 23.3.5.2 bitset operations:
+ //@{
+ /**
+ * Operations on bitsets.
+ * @param __rhs A same-sized bitset.
+ *
+ * These should be self-explanatory.
+ */
+ bitset<_Nb>&
+ operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
+ {
+ this->_M_do_and(__rhs);
+ return *this;
+ }
+
+ bitset<_Nb>&
+ operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
+ {
+ this->_M_do_or(__rhs);
+ return *this;
+ }
+
+ bitset<_Nb>&
+ operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
+ {
+ this->_M_do_xor(__rhs);
+ return *this;
+ }
+ //@}
+
+ //@{
+ /**
+ * Operations on bitsets.
+ * @param __position The number of places to shift.
+ *
+ * These should be self-explanatory.
+ */
+ bitset<_Nb>&
+ operator<<=(size_t __position) _GLIBCXX_NOEXCEPT
+ {
+ if (__builtin_expect(__position < _Nb, 1))
+ {
+ this->_M_do_left_shift(__position);
+ this->_M_do_sanitize();
+ }
+ else
+ this->_M_do_reset();
+ return *this;
+ }
+
+ bitset<_Nb>&
+ operator>>=(size_t __position) _GLIBCXX_NOEXCEPT
+ {
+ if (__builtin_expect(__position < _Nb, 1))
+ {
+ this->_M_do_right_shift(__position);
+ this->_M_do_sanitize();
+ }
+ else
+ this->_M_do_reset();
+ return *this;
+ }
+ //@}
+
+ //@{
+ /**
+ * These versions of single-bit set, reset, flip, and test are
+ * extensions from the SGI version. They do no range checking.
+ * @ingroup SGIextensions
+ */
+ bitset<_Nb>&
+ _Unchecked_set(size_t __pos) _GLIBCXX_NOEXCEPT
+ {
+ this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
+ return *this;
+ }
+
+ bitset<_Nb>&
+ _Unchecked_set(size_t __pos, int __val) _GLIBCXX_NOEXCEPT
+ {
+ if (__val)
+ this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
+ else
+ this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
+ return *this;
+ }
+
+ bitset<_Nb>&
+ _Unchecked_reset(size_t __pos) _GLIBCXX_NOEXCEPT
+ {
+ this->_M_getword(__pos) &= ~_Base::_S_maskbit(__pos);
+ return *this;
+ }
+
+ bitset<_Nb>&
+ _Unchecked_flip(size_t __pos) _GLIBCXX_NOEXCEPT
+ {
+ this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos);
+ return *this;
+ }
+
+ _GLIBCXX_CONSTEXPR bool
+ _Unchecked_test(size_t __pos) const _GLIBCXX_NOEXCEPT
+ { return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos))
+ != static_cast<_WordT>(0)); }
+ //@}
+
+ // Set, reset, and flip.
+ /**
+ * @brief Sets every bit to true.
+ */
+ bitset<_Nb>&
+ set() _GLIBCXX_NOEXCEPT
+ {
+ this->_M_do_set();
+ this->_M_do_sanitize();
+ return *this;
+ }
+
+ /**
+ * @brief Sets a given bit to a particular value.
+ * @param __position The index of the bit.
+ * @param __val Either true or false, defaults to true.
+ * @throw std::out_of_range If @a pos is bigger the size of the %set.
+ */
+ bitset<_Nb>&
+ set(size_t __position, bool __val = true)
+ {
+ this->_M_check(__position, __N("bitset::set"));
+ return _Unchecked_set(__position, __val);
+ }
+
+ /**
+ * @brief Sets every bit to false.
+ */
+ bitset<_Nb>&
+ reset() _GLIBCXX_NOEXCEPT
+ {
+ this->_M_do_reset();
+ return *this;
+ }
+
+ /**
+ * @brief Sets a given bit to false.
+ * @param __position The index of the bit.
+ * @throw std::out_of_range If @a pos is bigger the size of the %set.
+ *
+ * Same as writing @c set(pos,false).
+ */
+ bitset<_Nb>&
+ reset(size_t __position)
+ {
+ this->_M_check(__position, __N("bitset::reset"));
+ return _Unchecked_reset(__position);
+ }
+
+ /**
+ * @brief Toggles every bit to its opposite value.
+ */
+ bitset<_Nb>&
+ flip() _GLIBCXX_NOEXCEPT
+ {
+ this->_M_do_flip();
+ this->_M_do_sanitize();
+ return *this;
+ }
+
+ /**
+ * @brief Toggles a given bit to its opposite value.
+ * @param __position The index of the bit.
+ * @throw std::out_of_range If @a pos is bigger the size of the %set.
+ */
+ bitset<_Nb>&
+ flip(size_t __position)
+ {
+ this->_M_check(__position, __N("bitset::flip"));
+ return _Unchecked_flip(__position);
+ }
+
+ /// See the no-argument flip().
+ bitset<_Nb>
+ operator~() const _GLIBCXX_NOEXCEPT
+ { return bitset<_Nb>(*this).flip(); }
+
+ //@{
+ /**
+ * @brief Array-indexing support.
+ * @param __position Index into the %bitset.
+ * @return A bool for a <em>const %bitset</em>. For non-const
+ * bitsets, an instance of the reference proxy class.
+ * @note These operators do no range checking and throw no exceptions,
+ * as required by DR 11 to the standard.
+ *
+ * _GLIBCXX_RESOLVE_LIB_DEFECTS Note that this implementation already
+ * resolves DR 11 (items 1 and 2), but does not do the range-checking
+ * required by that DR's resolution. -pme
+ * The DR has since been changed: range-checking is a precondition
+ * (users' responsibility), and these functions must not throw. -pme
+ */
+ reference
+ operator[](size_t __position)
+ { return reference(*this, __position); }
+
+ _GLIBCXX_CONSTEXPR bool
+ operator[](size_t __position) const
+ { return _Unchecked_test(__position); }
+ //@}
+
+ /**
+ * @brief Returns a numerical interpretation of the %bitset.
+ * @return The integral equivalent of the bits.
+ * @throw std::overflow_error If there are too many bits to be
+ * represented in an @c unsigned @c long.
+ */
+ unsigned long
+ to_ulong() const
+ { return this->_M_do_to_ulong(); }
+
+#if __cplusplus >= 201103L
+ unsigned long long
+ to_ullong() const
+ { return this->_M_do_to_ullong(); }
+#endif
+
+ /**
+ * @brief Returns a character interpretation of the %bitset.
+ * @return The string equivalent of the bits.
+ *
+ * Note the ordering of the bits: decreasing character positions
+ * correspond to increasing bit positions (see the main class notes for
+ * an example).
+ */
+ template<class _CharT, class _Traits, class _Alloc>
+ std::basic_string<_CharT, _Traits, _Alloc>
+ to_string() const
+ {
+ std::basic_string<_CharT, _Traits, _Alloc> __result;
+ _M_copy_to_string(__result, _CharT('0'), _CharT('1'));
+ return __result;
+ }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 396. what are characters zero and one.
+ template<class _CharT, class _Traits, class _Alloc>
+ std::basic_string<_CharT, _Traits, _Alloc>
+ to_string(_CharT __zero, _CharT __one = _CharT('1')) const
+ {
+ std::basic_string<_CharT, _Traits, _Alloc> __result;
+ _M_copy_to_string(__result, __zero, __one);
+ return __result;
+ }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 434. bitset::to_string() hard to use.
+ template<class _CharT, class _Traits>
+ std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
+ to_string() const
+ { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 853. to_string needs updating with zero and one.
+ template<class _CharT, class _Traits>
+ std::basic_string<_CharT, _Traits, std::allocator<_CharT> >
+ to_string(_CharT __zero, _CharT __one = _CharT('1')) const
+ { return to_string<_CharT, _Traits,
+ std::allocator<_CharT> >(__zero, __one); }
+
+ template<class _CharT>
+ std::basic_string<_CharT, std::char_traits<_CharT>,
+ std::allocator<_CharT> >
+ to_string() const
+ {
+ return to_string<_CharT, std::char_traits<_CharT>,
+ std::allocator<_CharT> >();
+ }
+
+ template<class _CharT>
+ std::basic_string<_CharT, std::char_traits<_CharT>,
+ std::allocator<_CharT> >
+ to_string(_CharT __zero, _CharT __one = _CharT('1')) const
+ {
+ return to_string<_CharT, std::char_traits<_CharT>,
+ std::allocator<_CharT> >(__zero, __one);
+ }
+
+ std::basic_string<char, std::char_traits<char>, std::allocator<char> >
+ to_string() const
+ {
+ return to_string<char, std::char_traits<char>,
+ std::allocator<char> >();
+ }
+
+ std::basic_string<char, std::char_traits<char>, std::allocator<char> >
+ to_string(char __zero, char __one = '1') const
+ {
+ return to_string<char, std::char_traits<char>,
+ std::allocator<char> >(__zero, __one);
+ }
+
+ // Helper functions for string operations.
+ template<class _CharT, class _Traits>
+ void
+ _M_copy_from_ptr(const _CharT*, size_t, size_t, size_t,
+ _CharT, _CharT);
+
+ template<class _CharT, class _Traits, class _Alloc>
+ void
+ _M_copy_from_string(const std::basic_string<_CharT,
+ _Traits, _Alloc>& __s, size_t __pos, size_t __n,
+ _CharT __zero, _CharT __one)
+ { _M_copy_from_ptr<_CharT, _Traits>(__s.data(), __s.size(), __pos, __n,
+ __zero, __one); }
+
+ template<class _CharT, class _Traits, class _Alloc>
+ void
+ _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>&,
+ _CharT, _CharT) const;
+
+ // NB: Backward compat.
+ template<class _CharT, class _Traits, class _Alloc>
+ void
+ _M_copy_from_string(const std::basic_string<_CharT,
+ _Traits, _Alloc>& __s, size_t __pos, size_t __n)
+ { _M_copy_from_string(__s, __pos, __n, _CharT('0'), _CharT('1')); }
+
+ template<class _CharT, class _Traits, class _Alloc>
+ void
+ _M_copy_to_string(std::basic_string<_CharT, _Traits,_Alloc>& __s) const
+ { _M_copy_to_string(__s, _CharT('0'), _CharT('1')); }
+
+ /// Returns the number of bits which are set.
+ size_t
+ count() const _GLIBCXX_NOEXCEPT
+ { return this->_M_do_count(); }
+
+ /// Returns the total number of bits.
+ _GLIBCXX_CONSTEXPR size_t
+ size() const _GLIBCXX_NOEXCEPT
+ { return _Nb; }
+
+ //@{
+ /// These comparisons for equality/inequality are, well, @e bitwise.
+ bool
+ operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
+ { return this->_M_is_equal(__rhs); }
+
+ bool
+ operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
+ { return !this->_M_is_equal(__rhs); }
+ //@}
+
+ /**
+ * @brief Tests the value of a bit.
+ * @param __position The index of a bit.
+ * @return The value at @a pos.
+ * @throw std::out_of_range If @a pos is bigger the size of the %set.
+ */
+ bool
+ test(size_t __position) const
+ {
+ this->_M_check(__position, __N("bitset::test"));
+ return _Unchecked_test(__position);
+ }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 693. std::bitset::all() missing.
+ /**
+ * @brief Tests whether all the bits are on.
+ * @return True if all the bits are set.
+ */
+ bool
+ all() const _GLIBCXX_NOEXCEPT
+ { return this->template _M_are_all<_Nb>(); }
+
+ /**
+ * @brief Tests whether any of the bits are on.
+ * @return True if at least one bit is set.
+ */
+ bool
+ any() const _GLIBCXX_NOEXCEPT
+ { return this->_M_is_any(); }
+
+ /**
+ * @brief Tests whether any of the bits are on.
+ * @return True if none of the bits are set.
+ */
+ bool
+ none() const _GLIBCXX_NOEXCEPT
+ { return !this->_M_is_any(); }
+
+ //@{
+ /// Self-explanatory.
+ bitset<_Nb>
+ operator<<(size_t __position) const _GLIBCXX_NOEXCEPT
+ { return bitset<_Nb>(*this) <<= __position; }
+
+ bitset<_Nb>
+ operator>>(size_t __position) const _GLIBCXX_NOEXCEPT
+ { return bitset<_Nb>(*this) >>= __position; }
+ //@}
+
+ /**
+ * @brief Finds the index of the first "on" bit.
+ * @return The index of the first bit set, or size() if not found.
+ * @ingroup SGIextensions
+ * @sa _Find_next
+ */
+ size_t
+ _Find_first() const _GLIBCXX_NOEXCEPT
+ { return this->_M_do_find_first(_Nb); }
+
+ /**
+ * @brief Finds the index of the next "on" bit after prev.
+ * @return The index of the next bit set, or size() if not found.
+ * @param __prev Where to start searching.
+ * @ingroup SGIextensions
+ * @sa _Find_first
+ */
+ size_t
+ _Find_next(size_t __prev) const _GLIBCXX_NOEXCEPT
+ { return this->_M_do_find_next(__prev, _Nb); }
+ };
+
+ // Definitions of non-inline member functions.
+ template<size_t _Nb>
+ template<class _CharT, class _Traits>
+ void
+ bitset<_Nb>::
+ _M_copy_from_ptr(const _CharT* __s, size_t __len,
+ size_t __pos, size_t __n, _CharT __zero, _CharT __one)
+ {
+ reset();
+ const size_t __nbits = std::min(_Nb, std::min(__n, size_t(__len - __pos)));
+ for (size_t __i = __nbits; __i > 0; --__i)
+ {
+ const _CharT __c = __s[__pos + __nbits - __i];
+ if (_Traits::eq(__c, __zero))
+ ;
+ else if (_Traits::eq(__c, __one))
+ _Unchecked_set(__i - 1);
+ else
+ __throw_invalid_argument(__N("bitset::_M_copy_from_ptr"));
+ }
+ }
+
+ template<size_t _Nb>
+ template<class _CharT, class _Traits, class _Alloc>
+ void
+ bitset<_Nb>::
+ _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s,
+ _CharT __zero, _CharT __one) const
+ {
+ __s.assign(_Nb, __zero);
+ for (size_t __i = _Nb; __i > 0; --__i)
+ if (_Unchecked_test(__i - 1))
+ _Traits::assign(__s[_Nb - __i], __one);
+ }
+
+ // 23.3.5.3 bitset operations:
+ //@{
+ /**
+ * @brief Global bitwise operations on bitsets.
+ * @param __x A bitset.
+ * @param __y A bitset of the same size as @a __x.
+ * @return A new bitset.
+ *
+ * These should be self-explanatory.
+ */
+ template<size_t _Nb>
+ inline bitset<_Nb>
+ operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
+ {
+ bitset<_Nb> __result(__x);
+ __result &= __y;
+ return __result;
+ }
+
+ template<size_t _Nb>
+ inline bitset<_Nb>
+ operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
+ {
+ bitset<_Nb> __result(__x);
+ __result |= __y;
+ return __result;
+ }
+
+ template <size_t _Nb>
+ inline bitset<_Nb>
+ operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
+ {
+ bitset<_Nb> __result(__x);
+ __result ^= __y;
+ return __result;
+ }
+ //@}
+
+ //@{
+ /**
+ * @brief Global I/O operators for bitsets.
+ *
+ * Direct I/O between streams and bitsets is supported. Output is
+ * straightforward. Input will skip whitespace, only accept @a 0 and @a 1
+ * characters, and will only extract as many digits as the %bitset will
+ * hold.
+ */
+ template<class _CharT, class _Traits, size_t _Nb>
+ std::basic_istream<_CharT, _Traits>&
+ operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
+ {
+ typedef typename _Traits::char_type char_type;
+ typedef std::basic_istream<_CharT, _Traits> __istream_type;
+ typedef typename __istream_type::ios_base __ios_base;
+
+ std::basic_string<_CharT, _Traits> __tmp;
+ __tmp.reserve(_Nb);
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 303. Bitset input operator underspecified
+ const char_type __zero = __is.widen('0');
+ const char_type __one = __is.widen('1');
+
+ typename __ios_base::iostate __state = __ios_base::goodbit;
+ typename __istream_type::sentry __sentry(__is);
+ if (__sentry)
+ {
+ __try
+ {
+ for (size_t __i = _Nb; __i > 0; --__i)
+ {
+ static typename _Traits::int_type __eof = _Traits::eof();
+
+ typename _Traits::int_type __c1 = __is.rdbuf()->sbumpc();
+ if (_Traits::eq_int_type(__c1, __eof))
+ {
+ __state |= __ios_base::eofbit;
+ break;
+ }
+ else
+ {
+ const char_type __c2 = _Traits::to_char_type(__c1);
+ if (_Traits::eq(__c2, __zero))
+ __tmp.push_back(__zero);
+ else if (_Traits::eq(__c2, __one))
+ __tmp.push_back(__one);
+ else if (_Traits::
+ eq_int_type(__is.rdbuf()->sputbackc(__c2),
+ __eof))
+ {
+ __state |= __ios_base::failbit;
+ break;
+ }
+ }
+ }
+ }
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ __is._M_setstate(__ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
+ { __is._M_setstate(__ios_base::badbit); }
+ }
+
+ if (__tmp.empty() && _Nb)
+ __state |= __ios_base::failbit;
+ else
+ __x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb,
+ __zero, __one);
+ if (__state)
+ __is.setstate(__state);
+ return __is;
+ }
+
+ template <class _CharT, class _Traits, size_t _Nb>
+ std::basic_ostream<_CharT, _Traits>&
+ operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+ const bitset<_Nb>& __x)
+ {
+ std::basic_string<_CharT, _Traits> __tmp;
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 396. what are characters zero and one.
+ const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__os.getloc());
+ __x._M_copy_to_string(__tmp, __ct.widen('0'), __ct.widen('1'));
+ return __os << __tmp;
+ }
+ //@}
+
+_GLIBCXX_END_NAMESPACE_CONTAINER
+} // namespace std
+
+#undef _GLIBCXX_BITSET_WORDS
+#undef _GLIBCXX_BITSET_BITS_PER_WORD
+#undef _GLIBCXX_BITSET_BITS_PER_ULL
+
+#if __cplusplus >= 201103L
+
+#include <bits/functional_hash.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // DR 1182.
+ /// std::hash specialization for bitset.
+ template<size_t _Nb>
+ struct hash<_GLIBCXX_STD_C::bitset<_Nb>>
+ : public __hash_base<size_t, _GLIBCXX_STD_C::bitset<_Nb>>
+ {
+ size_t
+ operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const noexcept
+ {
+ const size_t __clength = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__;
+ return std::_Hash_impl::hash(__b._M_getdata(), __clength);
+ }
+ };
+
+ template<>
+ struct hash<_GLIBCXX_STD_C::bitset<0>>
+ : public __hash_base<size_t, _GLIBCXX_STD_C::bitset<0>>
+ {
+ size_t
+ operator()(const _GLIBCXX_STD_C::bitset<0>&) const noexcept
+ { return 0; }
+ };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif // C++11
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/bitset>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/bitset>
+#endif
+
+#endif /* _GLIBCXX_BITSET */
diff --git a/gcc-4.9/libstdc++-v3/include/std/chrono b/gcc-4.9/libstdc++-v3/include/std/chrono
new file mode 100644
index 0000000..b114e02
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/chrono
@@ -0,0 +1,914 @@
+// <chrono> -*- C++ -*-
+
+// Copyright (C) 2008-2014 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/chrono
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_CHRONO
+#define _GLIBCXX_CHRONO 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <ratio>
+#include <type_traits>
+#include <limits>
+#include <ctime>
+#include <bits/parse_numbers.h> // for literals support.
+
+#ifdef _GLIBCXX_USE_C99_STDINT_TR1
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+ /**
+ * @defgroup chrono Time
+ * @ingroup utilities
+ *
+ * Classes and functions for time.
+ * @{
+ */
+
+ /** @namespace std::chrono
+ * @brief ISO C++ 2011 entities sub-namespace for time and date.
+ */
+ namespace chrono
+ {
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _Rep, typename _Period = ratio<1>>
+ struct duration;
+
+ template<typename _Clock, typename _Dur = typename _Clock::duration>
+ struct time_point;
+
+ _GLIBCXX_END_NAMESPACE_VERSION
+ }
+
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // 20.11.4.3 specialization of common_type (for duration, sfinae-friendly)
+
+ template<typename _CT, typename _Period1, typename _Period2>
+ struct __duration_common_type_wrapper
+ {
+ private:
+ typedef __static_gcd<_Period1::num, _Period2::num> __gcd_num;
+ typedef __static_gcd<_Period1::den, _Period2::den> __gcd_den;
+ typedef typename _CT::type __cr;
+ typedef ratio<__gcd_num::value,
+ (_Period1::den / __gcd_den::value) * _Period2::den> __r;
+ public:
+ typedef __success_type<chrono::duration<__cr, __r>> type;
+ };
+
+ template<typename _Period1, typename _Period2>
+ struct __duration_common_type_wrapper<__failure_type, _Period1, _Period2>
+ { typedef __failure_type type; };
+
+ template<typename _Rep1, typename _Period1, typename _Rep2, typename _Period2>
+ struct common_type<chrono::duration<_Rep1, _Period1>,
+ chrono::duration<_Rep2, _Period2>>
+ : public __duration_common_type_wrapper<typename __member_type_wrapper<
+ common_type<_Rep1, _Rep2>>::type, _Period1, _Period2>::type
+ { };
+
+ // 20.11.4.3 specialization of common_type (for time_point, sfinae-friendly)
+
+ template<typename _CT, typename _Clock>
+ struct __timepoint_common_type_wrapper
+ {
+ typedef __success_type<chrono::time_point<_Clock, typename _CT::type>>
+ type;
+ };
+
+ template<typename _Clock>
+ struct __timepoint_common_type_wrapper<__failure_type, _Clock>
+ { typedef __failure_type type; };
+
+ template<typename _Clock, typename _Duration1, typename _Duration2>
+ struct common_type<chrono::time_point<_Clock, _Duration1>,
+ chrono::time_point<_Clock, _Duration2>>
+ : public __timepoint_common_type_wrapper<typename __member_type_wrapper<
+ common_type<_Duration1, _Duration2>>::type, _Clock>::type
+ { };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+
+ namespace chrono
+ {
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // Primary template for duration_cast impl.
+ template<typename _ToDur, typename _CF, typename _CR,
+ bool _NumIsOne = false, bool _DenIsOne = false>
+ struct __duration_cast_impl
+ {
+ template<typename _Rep, typename _Period>
+ static constexpr _ToDur
+ __cast(const duration<_Rep, _Period>& __d)
+ {
+ typedef typename _ToDur::rep __to_rep;
+ return _ToDur(static_cast<__to_rep>(static_cast<_CR>(__d.count())
+ * static_cast<_CR>(_CF::num)
+ / static_cast<_CR>(_CF::den)));
+ }
+ };
+
+ template<typename _ToDur, typename _CF, typename _CR>
+ struct __duration_cast_impl<_ToDur, _CF, _CR, true, true>
+ {
+ template<typename _Rep, typename _Period>
+ static constexpr _ToDur
+ __cast(const duration<_Rep, _Period>& __d)
+ {
+ typedef typename _ToDur::rep __to_rep;
+ return _ToDur(static_cast<__to_rep>(__d.count()));
+ }
+ };
+
+ template<typename _ToDur, typename _CF, typename _CR>
+ struct __duration_cast_impl<_ToDur, _CF, _CR, true, false>
+ {
+ template<typename _Rep, typename _Period>
+ static constexpr _ToDur
+ __cast(const duration<_Rep, _Period>& __d)
+ {
+ typedef typename _ToDur::rep __to_rep;
+ return _ToDur(static_cast<__to_rep>(
+ static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den)));
+ }
+ };
+
+ template<typename _ToDur, typename _CF, typename _CR>
+ struct __duration_cast_impl<_ToDur, _CF, _CR, false, true>
+ {
+ template<typename _Rep, typename _Period>
+ static constexpr _ToDur
+ __cast(const duration<_Rep, _Period>& __d)
+ {
+ typedef typename _ToDur::rep __to_rep;
+ return _ToDur(static_cast<__to_rep>(
+ static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num)));
+ }
+ };
+
+ template<typename _Tp>
+ struct __is_duration
+ : std::false_type
+ { };
+
+ template<typename _Rep, typename _Period>
+ struct __is_duration<duration<_Rep, _Period>>
+ : std::true_type
+ { };
+
+ /// duration_cast
+ template<typename _ToDur, typename _Rep, typename _Period>
+ constexpr typename enable_if<__is_duration<_ToDur>::value,
+ _ToDur>::type
+ duration_cast(const duration<_Rep, _Period>& __d)
+ {
+ typedef typename _ToDur::period __to_period;
+ typedef typename _ToDur::rep __to_rep;
+ typedef ratio_divide<_Period, __to_period> __cf;
+ typedef typename common_type<__to_rep, _Rep, intmax_t>::type
+ __cr;
+ typedef __duration_cast_impl<_ToDur, __cf, __cr,
+ __cf::num == 1, __cf::den == 1> __dc;
+ return __dc::__cast(__d);
+ }
+
+ /// treat_as_floating_point
+ template<typename _Rep>
+ struct treat_as_floating_point
+ : is_floating_point<_Rep>
+ { };
+
+ /// duration_values
+ template<typename _Rep>
+ struct duration_values
+ {
+ static constexpr _Rep
+ zero()
+ { return _Rep(0); }
+
+ static constexpr _Rep
+ max()
+ { return numeric_limits<_Rep>::max(); }
+
+ static constexpr _Rep
+ min()
+ { return numeric_limits<_Rep>::lowest(); }
+ };
+
+ template<typename _Tp>
+ struct __is_ratio
+ : std::false_type
+ { };
+
+ template<intmax_t _Num, intmax_t _Den>
+ struct __is_ratio<ratio<_Num, _Den>>
+ : std::true_type
+ { };
+
+ /// duration
+ template<typename _Rep, typename _Period>
+ struct duration
+ {
+ typedef _Rep rep;
+ typedef _Period period;
+
+ static_assert(!__is_duration<_Rep>::value, "rep cannot be a duration");
+ static_assert(__is_ratio<_Period>::value,
+ "period must be a specialization of ratio");
+ static_assert(_Period::num > 0, "period must be positive");
+
+ // 20.11.5.1 construction / copy / destroy
+ constexpr duration() = default;
+
+ // NB: Make constexpr implicit. This cannot be explicitly
+ // constexpr, as any UDT that is not a literal type with a
+ // constexpr copy constructor will be ill-formed.
+ duration(const duration&) = default;
+
+ template<typename _Rep2, typename = typename
+ enable_if<is_convertible<_Rep2, rep>::value
+ && (treat_as_floating_point<rep>::value
+ || !treat_as_floating_point<_Rep2>::value)>::type>
+ constexpr explicit duration(const _Rep2& __rep)
+ : __r(static_cast<rep>(__rep)) { }
+
+ template<typename _Rep2, typename _Period2, typename = typename
+ enable_if<treat_as_floating_point<rep>::value
+ || (ratio_divide<_Period2, period>::den == 1
+ && !treat_as_floating_point<_Rep2>::value)>::type>
+ constexpr duration(const duration<_Rep2, _Period2>& __d)
+ : __r(duration_cast<duration>(__d).count()) { }
+
+ ~duration() = default;
+ duration& operator=(const duration&) = default;
+
+ // 20.11.5.2 observer
+ constexpr rep
+ count() const
+ { return __r; }
+
+ // 20.11.5.3 arithmetic
+ constexpr duration
+ operator+() const
+ { return *this; }
+
+ constexpr duration
+ operator-() const
+ { return duration(-__r); }
+
+ duration&
+ operator++()
+ {
+ ++__r;
+ return *this;
+ }
+
+ duration
+ operator++(int)
+ { return duration(__r++); }
+
+ duration&
+ operator--()
+ {
+ --__r;
+ return *this;
+ }
+
+ duration
+ operator--(int)
+ { return duration(__r--); }
+
+ duration&
+ operator+=(const duration& __d)
+ {
+ __r += __d.count();
+ return *this;
+ }
+
+ duration&
+ operator-=(const duration& __d)
+ {
+ __r -= __d.count();
+ return *this;
+ }
+
+ duration&
+ operator*=(const rep& __rhs)
+ {
+ __r *= __rhs;
+ return *this;
+ }
+
+ duration&
+ operator/=(const rep& __rhs)
+ {
+ __r /= __rhs;
+ return *this;
+ }
+
+ // DR 934.
+ template<typename _Rep2 = rep>
+ typename enable_if<!treat_as_floating_point<_Rep2>::value,
+ duration&>::type
+ operator%=(const rep& __rhs)
+ {
+ __r %= __rhs;
+ return *this;
+ }
+
+ template<typename _Rep2 = rep>
+ typename enable_if<!treat_as_floating_point<_Rep2>::value,
+ duration&>::type
+ operator%=(const duration& __d)
+ {
+ __r %= __d.count();
+ return *this;
+ }
+
+ // 20.11.5.4 special values
+ static constexpr duration
+ zero()
+ { return duration(duration_values<rep>::zero()); }
+
+ static constexpr duration
+ min()
+ { return duration(duration_values<rep>::min()); }
+
+ static constexpr duration
+ max()
+ { return duration(duration_values<rep>::max()); }
+
+ private:
+ rep __r;
+ };
+
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr typename common_type<duration<_Rep1, _Period1>,
+ duration<_Rep2, _Period2>>::type
+ operator+(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ {
+ typedef duration<_Rep1, _Period1> __dur1;
+ typedef duration<_Rep2, _Period2> __dur2;
+ typedef typename common_type<__dur1,__dur2>::type __cd;
+ return __cd(__cd(__lhs).count() + __cd(__rhs).count());
+ }
+
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr typename common_type<duration<_Rep1, _Period1>,
+ duration<_Rep2, _Period2>>::type
+ operator-(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ {
+ typedef duration<_Rep1, _Period1> __dur1;
+ typedef duration<_Rep2, _Period2> __dur2;
+ typedef typename common_type<__dur1,__dur2>::type __cd;
+ return __cd(__cd(__lhs).count() - __cd(__rhs).count());
+ }
+
+ template<typename _Rep1, typename _Rep2, bool =
+ is_convertible<_Rep2,
+ typename common_type<_Rep1, _Rep2>::type>::value>
+ struct __common_rep_type { };
+
+ template<typename _Rep1, typename _Rep2>
+ struct __common_rep_type<_Rep1, _Rep2, true>
+ { typedef typename common_type<_Rep1, _Rep2>::type type; };
+
+ template<typename _Rep1, typename _Period, typename _Rep2>
+ constexpr
+ duration<typename __common_rep_type<_Rep1, _Rep2>::type, _Period>
+ operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
+ {
+ typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+ __cd;
+ return __cd(__cd(__d).count() * __s);
+ }
+
+ template<typename _Rep1, typename _Rep2, typename _Period>
+ constexpr
+ duration<typename __common_rep_type<_Rep2, _Rep1>::type, _Period>
+ operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
+ { return __d * __s; }
+
+ template<typename _Rep1, typename _Period, typename _Rep2>
+ constexpr duration<typename __common_rep_type<_Rep1, typename
+ enable_if<!__is_duration<_Rep2>::value, _Rep2>::type>::type, _Period>
+ operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
+ {
+ typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+ __cd;
+ return __cd(__cd(__d).count() / __s);
+ }
+
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr typename common_type<_Rep1, _Rep2>::type
+ operator/(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ {
+ typedef duration<_Rep1, _Period1> __dur1;
+ typedef duration<_Rep2, _Period2> __dur2;
+ typedef typename common_type<__dur1,__dur2>::type __cd;
+ return __cd(__lhs).count() / __cd(__rhs).count();
+ }
+
+ // DR 934.
+ template<typename _Rep1, typename _Period, typename _Rep2>
+ constexpr duration<typename __common_rep_type<_Rep1, typename
+ enable_if<!__is_duration<_Rep2>::value, _Rep2>::type>::type, _Period>
+ operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
+ {
+ typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+ __cd;
+ return __cd(__cd(__d).count() % __s);
+ }
+
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr typename common_type<duration<_Rep1, _Period1>,
+ duration<_Rep2, _Period2>>::type
+ operator%(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ {
+ typedef duration<_Rep1, _Period1> __dur1;
+ typedef duration<_Rep2, _Period2> __dur2;
+ typedef typename common_type<__dur1,__dur2>::type __cd;
+ return __cd(__cd(__lhs).count() % __cd(__rhs).count());
+ }
+
+ // comparisons
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr bool
+ operator==(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ {
+ typedef duration<_Rep1, _Period1> __dur1;
+ typedef duration<_Rep2, _Period2> __dur2;
+ typedef typename common_type<__dur1,__dur2>::type __ct;
+ return __ct(__lhs).count() == __ct(__rhs).count();
+ }
+
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr bool
+ operator<(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ {
+ typedef duration<_Rep1, _Period1> __dur1;
+ typedef duration<_Rep2, _Period2> __dur2;
+ typedef typename common_type<__dur1,__dur2>::type __ct;
+ return __ct(__lhs).count() < __ct(__rhs).count();
+ }
+
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr bool
+ operator!=(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ { return !(__lhs == __rhs); }
+
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr bool
+ operator<=(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ { return !(__rhs < __lhs); }
+
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr bool
+ operator>(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ { return __rhs < __lhs; }
+
+ template<typename _Rep1, typename _Period1,
+ typename _Rep2, typename _Period2>
+ constexpr bool
+ operator>=(const duration<_Rep1, _Period1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ { return !(__lhs < __rhs); }
+
+ /// nanoseconds
+ typedef duration<int64_t, nano> nanoseconds;
+
+ /// microseconds
+ typedef duration<int64_t, micro> microseconds;
+
+ /// milliseconds
+ typedef duration<int64_t, milli> milliseconds;
+
+ /// seconds
+ typedef duration<int64_t> seconds;
+
+ /// minutes
+ typedef duration<int64_t, ratio< 60>> minutes;
+
+ /// hours
+ typedef duration<int64_t, ratio<3600>> hours;
+
+ /// time_point
+ template<typename _Clock, typename _Dur>
+ struct time_point
+ {
+ typedef _Clock clock;
+ typedef _Dur duration;
+ typedef typename duration::rep rep;
+ typedef typename duration::period period;
+
+ constexpr time_point() : __d(duration::zero())
+ { }
+
+ constexpr explicit time_point(const duration& __dur)
+ : __d(__dur)
+ { }
+
+ // conversions
+ template<typename _Dur2>
+ constexpr time_point(const time_point<clock, _Dur2>& __t)
+ : __d(__t.time_since_epoch())
+ { }
+
+ // observer
+ constexpr duration
+ time_since_epoch() const
+ { return __d; }
+
+ // arithmetic
+ time_point&
+ operator+=(const duration& __dur)
+ {
+ __d += __dur;
+ return *this;
+ }
+
+ time_point&
+ operator-=(const duration& __dur)
+ {
+ __d -= __dur;
+ return *this;
+ }
+
+ // special values
+ static constexpr time_point
+ min()
+ { return time_point(duration::min()); }
+
+ static constexpr time_point
+ max()
+ { return time_point(duration::max()); }
+
+ private:
+ duration __d;
+ };
+
+ /// time_point_cast
+ template<typename _ToDur, typename _Clock, typename _Dur>
+ constexpr typename enable_if<__is_duration<_ToDur>::value,
+ time_point<_Clock, _ToDur>>::type
+ time_point_cast(const time_point<_Clock, _Dur>& __t)
+ {
+ typedef time_point<_Clock, _ToDur> __time_point;
+ return __time_point(duration_cast<_ToDur>(__t.time_since_epoch()));
+ }
+
+ template<typename _Clock, typename _Dur1,
+ typename _Rep2, typename _Period2>
+ constexpr time_point<_Clock,
+ typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
+ operator+(const time_point<_Clock, _Dur1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ {
+ typedef duration<_Rep2, _Period2> __dur2;
+ typedef typename common_type<_Dur1,__dur2>::type __ct;
+ typedef time_point<_Clock, __ct> __time_point;
+ return __time_point(__lhs.time_since_epoch() + __rhs);
+ }
+
+ template<typename _Rep1, typename _Period1,
+ typename _Clock, typename _Dur2>
+ constexpr time_point<_Clock,
+ typename common_type<duration<_Rep1, _Period1>, _Dur2>::type>
+ operator+(const duration<_Rep1, _Period1>& __lhs,
+ const time_point<_Clock, _Dur2>& __rhs)
+ {
+ typedef duration<_Rep1, _Period1> __dur1;
+ typedef typename common_type<__dur1,_Dur2>::type __ct;
+ typedef time_point<_Clock, __ct> __time_point;
+ return __time_point(__rhs.time_since_epoch() + __lhs);
+ }
+
+ template<typename _Clock, typename _Dur1,
+ typename _Rep2, typename _Period2>
+ constexpr time_point<_Clock,
+ typename common_type<_Dur1, duration<_Rep2, _Period2>>::type>
+ operator-(const time_point<_Clock, _Dur1>& __lhs,
+ const duration<_Rep2, _Period2>& __rhs)
+ {
+ typedef duration<_Rep2, _Period2> __dur2;
+ typedef typename common_type<_Dur1,__dur2>::type __ct;
+ typedef time_point<_Clock, __ct> __time_point;
+ return __time_point(__lhs.time_since_epoch() -__rhs);
+ }
+
+ template<typename _Clock, typename _Dur1, typename _Dur2>
+ constexpr typename common_type<_Dur1, _Dur2>::type
+ operator-(const time_point<_Clock, _Dur1>& __lhs,
+ const time_point<_Clock, _Dur2>& __rhs)
+ { return __lhs.time_since_epoch() - __rhs.time_since_epoch(); }
+
+ template<typename _Clock, typename _Dur1, typename _Dur2>
+ constexpr bool
+ operator==(const time_point<_Clock, _Dur1>& __lhs,
+ const time_point<_Clock, _Dur2>& __rhs)
+ { return __lhs.time_since_epoch() == __rhs.time_since_epoch(); }
+
+ template<typename _Clock, typename _Dur1, typename _Dur2>
+ constexpr bool
+ operator!=(const time_point<_Clock, _Dur1>& __lhs,
+ const time_point<_Clock, _Dur2>& __rhs)
+ { return !(__lhs == __rhs); }
+
+ template<typename _Clock, typename _Dur1, typename _Dur2>
+ constexpr bool
+ operator<(const time_point<_Clock, _Dur1>& __lhs,
+ const time_point<_Clock, _Dur2>& __rhs)
+ { return __lhs.time_since_epoch() < __rhs.time_since_epoch(); }
+
+ template<typename _Clock, typename _Dur1, typename _Dur2>
+ constexpr bool
+ operator<=(const time_point<_Clock, _Dur1>& __lhs,
+ const time_point<_Clock, _Dur2>& __rhs)
+ { return !(__rhs < __lhs); }
+
+ template<typename _Clock, typename _Dur1, typename _Dur2>
+ constexpr bool
+ operator>(const time_point<_Clock, _Dur1>& __lhs,
+ const time_point<_Clock, _Dur2>& __rhs)
+ { return __rhs < __lhs; }
+
+ template<typename _Clock, typename _Dur1, typename _Dur2>
+ constexpr bool
+ operator>=(const time_point<_Clock, _Dur1>& __lhs,
+ const time_point<_Clock, _Dur2>& __rhs)
+ { return !(__lhs < __rhs); }
+
+
+ // Clocks.
+
+ // Why nanosecond resolution as the default?
+ // Why have std::system_clock always count in the higest
+ // resolution (ie nanoseconds), even if on some OSes the low 3
+ // or 9 decimal digits will be always zero? This allows later
+ // implementations to change the system_clock::now()
+ // implementation any time to provide better resolution without
+ // changing function signature or units.
+
+ // To support the (forward) evolution of the library's defined
+ // clocks, wrap inside inline namespace so that the current
+ // defintions of system_clock, steady_clock, and
+ // high_resolution_clock types are uniquely mangled. This way, new
+ // code can use the latests clocks, while the library can contain
+ // compatibility definitions for previous versions. At some
+ // point, when these clocks settle down, the inlined namespaces
+ // can be removed. XXX GLIBCXX_ABI Deprecated
+ inline namespace _V2 {
+
+ /**
+ * @brief System clock.
+ *
+ * Time returned represents wall time from the system-wide clock.
+ */
+ struct system_clock
+ {
+ typedef chrono::nanoseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef chrono::time_point<system_clock, duration> time_point;
+
+ static_assert(system_clock::duration::min()
+ < system_clock::duration::zero(),
+ "a clock's minimum duration cannot be less than its epoch");
+
+ static constexpr bool is_steady = false;
+
+ static time_point
+ now() noexcept;
+
+ // Map to C API
+ static std::time_t
+ to_time_t(const time_point& __t) noexcept
+ {
+ return std::time_t(duration_cast<chrono::seconds>
+ (__t.time_since_epoch()).count());
+ }
+
+ static time_point
+ from_time_t(std::time_t __t) noexcept
+ {
+ typedef chrono::time_point<system_clock, seconds> __from;
+ return time_point_cast<system_clock::duration>
+ (__from(chrono::seconds(__t)));
+ }
+ };
+
+
+ /**
+ * @brief Monotonic clock
+ *
+ * Time returned has the property of only increasing at a uniform rate.
+ */
+ struct steady_clock
+ {
+ typedef chrono::nanoseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef chrono::time_point<steady_clock, duration> time_point;
+
+ static constexpr bool is_steady = true;
+
+ static time_point
+ now() noexcept;
+ };
+
+
+ /**
+ * @brief Highest-resolution clock
+ *
+ * This is the clock "with the shortest tick period." Alias to
+ * std::system_clock until higher-than-nanosecond definitions
+ * become feasible.
+ */
+ using high_resolution_clock = system_clock;
+
+ } // end inline namespace _V2
+
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace chrono
+
+#if __cplusplus > 201103L
+
+ inline namespace literals
+ {
+ inline namespace chrono_literals
+ {
+
+ namespace __select_type
+ {
+
+ using namespace __parse_int;
+
+ template<unsigned long long _Val, typename _Dur>
+ struct _Select_type
+ : conditional<
+ _Val <= static_cast<unsigned long long>
+ (numeric_limits<typename _Dur::rep>::max()),
+ _Dur, void>
+ {
+ static constexpr typename _Select_type::type
+ value{static_cast<typename _Select_type::type>(_Val)};
+ };
+
+ template<unsigned long long _Val, typename _Dur>
+ constexpr typename _Select_type<_Val, _Dur>::type
+ _Select_type<_Val, _Dur>::value;
+
+ } // __select_type
+
+ constexpr chrono::duration<long double, ratio<3600,1>>
+ operator""h(long double __hours)
+ { return chrono::duration<long double, ratio<3600,1>>{__hours}; }
+
+ template <char... _Digits>
+ constexpr typename
+ __select_type::_Select_type<__select_int::_Select_int<_Digits...>::value,
+ chrono::hours>::type
+ operator""h()
+ {
+ return __select_type::_Select_type<
+ __select_int::_Select_int<_Digits...>::value,
+ chrono::hours>::value;
+ }
+
+ constexpr chrono::duration<long double, ratio<60,1>>
+ operator""min(long double __mins)
+ { return chrono::duration<long double, ratio<60,1>>{__mins}; }
+
+ template <char... _Digits>
+ constexpr typename
+ __select_type::_Select_type<__select_int::_Select_int<_Digits...>::value,
+ chrono::minutes>::type
+ operator""min()
+ {
+ return __select_type::_Select_type<
+ __select_int::_Select_int<_Digits...>::value,
+ chrono::minutes>::value;
+ }
+
+ constexpr chrono::duration<long double>
+ operator""s(long double __secs)
+ { return chrono::duration<long double>{__secs}; }
+
+ template <char... _Digits>
+ constexpr typename
+ __select_type::_Select_type<__select_int::_Select_int<_Digits...>::value,
+ chrono::seconds>::type
+ operator""s()
+ {
+ return __select_type::_Select_type<
+ __select_int::_Select_int<_Digits...>::value,
+ chrono::seconds>::value;
+ }
+
+ constexpr chrono::duration<long double, milli>
+ operator""ms(long double __msecs)
+ { return chrono::duration<long double, milli>{__msecs}; }
+
+ template <char... _Digits>
+ constexpr typename
+ __select_type::_Select_type<__select_int::_Select_int<_Digits...>::value,
+ chrono::milliseconds>::type
+ operator""ms()
+ {
+ return __select_type::_Select_type<
+ __select_int::_Select_int<_Digits...>::value,
+ chrono::milliseconds>::value;
+ }
+
+ constexpr chrono::duration<long double, micro>
+ operator""us(long double __usecs)
+ { return chrono::duration<long double, micro>{__usecs}; }
+
+ template <char... _Digits>
+ constexpr typename
+ __select_type::_Select_type<__select_int::_Select_int<_Digits...>::value,
+ chrono::microseconds>::type
+ operator""us()
+ {
+ return __select_type::_Select_type<
+ __select_int::_Select_int<_Digits...>::value,
+ chrono::microseconds>::value;
+ }
+
+ constexpr chrono::duration<long double, nano>
+ operator""ns(long double __nsecs)
+ { return chrono::duration<long double, nano>{__nsecs}; }
+
+ template <char... _Digits>
+ constexpr typename
+ __select_type::_Select_type<__select_int::_Select_int<_Digits...>::value,
+ chrono::nanoseconds>::type
+ operator""ns()
+ {
+ return __select_type::_Select_type<
+ __select_int::_Select_int<_Digits...>::value,
+ chrono::nanoseconds>::value;
+ }
+
+ } // inline namespace chrono_literals
+ } // inline namespace literals
+
+#endif // __cplusplus > 201103L
+
+ // @} group chrono
+} // namespace std
+
+#endif //_GLIBCXX_USE_C99_STDINT_TR1
+
+#endif // C++11
+
+#endif //_GLIBCXX_CHRONO
diff --git a/gcc-4.9/libstdc++-v3/include/std/complex b/gcc-4.9/libstdc++-v3/include/std/complex
new file mode 100644
index 0000000..34fa1dd
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/complex
@@ -0,0 +1,1966 @@
+// The template and inlines for the -*- C++ -*- complex number classes.
+
+// Copyright (C) 1997-2014 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/complex
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 26.2 Complex Numbers
+// Note: this is not a conforming implementation.
+// Initially implemented by Ulrich Drepper <drepper@cygnus.com>
+// Improved by Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
+//
+
+#ifndef _GLIBCXX_COMPLEX
+#define _GLIBCXX_COMPLEX 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <bits/cpp_type_traits.h>
+#include <ext/type_traits.h>
+#include <cmath>
+#include <sstream>
+
+// Get rid of a macro possibly defined in <complex.h>
+#undef complex
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @defgroup complex_numbers Complex Numbers
+ * @ingroup numerics
+ *
+ * Classes and functions for complex numbers.
+ * @{
+ */
+
+ // Forward declarations.
+ template<typename _Tp> class complex;
+ template<> class complex<float>;
+ template<> class complex<double>;
+ template<> class complex<long double>;
+
+ /// Return magnitude of @a z.
+ template<typename _Tp> _Tp abs(const complex<_Tp>&);
+ /// Return phase angle of @a z.
+ template<typename _Tp> _Tp arg(const complex<_Tp>&);
+ /// Return @a z magnitude squared.
+ template<typename _Tp> _Tp norm(const complex<_Tp>&);
+
+ /// Return complex conjugate of @a z.
+ template<typename _Tp> complex<_Tp> conj(const complex<_Tp>&);
+ /// Return complex with magnitude @a rho and angle @a theta.
+ template<typename _Tp> complex<_Tp> polar(const _Tp&, const _Tp& = 0);
+
+ // Transcendentals:
+ /// Return complex cosine of @a z.
+ template<typename _Tp> complex<_Tp> cos(const complex<_Tp>&);
+ /// Return complex hyperbolic cosine of @a z.
+ template<typename _Tp> complex<_Tp> cosh(const complex<_Tp>&);
+ /// Return complex base e exponential of @a z.
+ template<typename _Tp> complex<_Tp> exp(const complex<_Tp>&);
+ /// Return complex natural logarithm of @a z.
+ template<typename _Tp> complex<_Tp> log(const complex<_Tp>&);
+ /// Return complex base 10 logarithm of @a z.
+ template<typename _Tp> complex<_Tp> log10(const complex<_Tp>&);
+ /// Return @a x to the @a y'th power.
+ template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, int);
+ /// Return @a x to the @a y'th power.
+ template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&, const _Tp&);
+ /// Return @a x to the @a y'th power.
+ template<typename _Tp> complex<_Tp> pow(const complex<_Tp>&,
+ const complex<_Tp>&);
+ /// Return @a x to the @a y'th power.
+ template<typename _Tp> complex<_Tp> pow(const _Tp&, const complex<_Tp>&);
+ /// Return complex sine of @a z.
+ template<typename _Tp> complex<_Tp> sin(const complex<_Tp>&);
+ /// Return complex hyperbolic sine of @a z.
+ template<typename _Tp> complex<_Tp> sinh(const complex<_Tp>&);
+ /// Return complex square root of @a z.
+ template<typename _Tp> complex<_Tp> sqrt(const complex<_Tp>&);
+ /// Return complex tangent of @a z.
+ template<typename _Tp> complex<_Tp> tan(const complex<_Tp>&);
+ /// Return complex hyperbolic tangent of @a z.
+ template<typename _Tp> complex<_Tp> tanh(const complex<_Tp>&);
+
+
+ // 26.2.2 Primary template class complex
+ /**
+ * Template to represent complex numbers.
+ *
+ * Specializations for float, double, and long double are part of the
+ * library. Results with any other type are not guaranteed.
+ *
+ * @param Tp Type of real and imaginary values.
+ */
+ template<typename _Tp>
+ struct complex
+ {
+ /// Value typedef.
+ typedef _Tp value_type;
+
+ /// Default constructor. First parameter is x, second parameter is y.
+ /// Unspecified parameters default to 0.
+ _GLIBCXX_CONSTEXPR complex(const _Tp& __r = _Tp(), const _Tp& __i = _Tp())
+ : _M_real(__r), _M_imag(__i) { }
+
+ // Lets the compiler synthesize the copy constructor
+ // complex (const complex<_Tp>&);
+ /// Copy constructor.
+ template<typename _Up>
+ _GLIBCXX_CONSTEXPR complex(const complex<_Up>& __z)
+ : _M_real(__z.real()), _M_imag(__z.imag()) { }
+
+#if __cplusplus >= 201103L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 387. std::complex over-encapsulated.
+ _GLIBCXX_ABI_TAG_CXX11
+ constexpr _Tp
+ real() { return _M_real; }
+
+ _GLIBCXX_ABI_TAG_CXX11
+ constexpr _Tp
+ imag() { return _M_imag; }
+#else
+ /// Return real part of complex number.
+ _Tp&
+ real() { return _M_real; }
+
+ /// Return real part of complex number.
+ const _Tp&
+ real() const { return _M_real; }
+
+ /// Return imaginary part of complex number.
+ _Tp&
+ imag() { return _M_imag; }
+
+ /// Return imaginary part of complex number.
+ const _Tp&
+ imag() const { return _M_imag; }
+#endif
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 387. std::complex over-encapsulated.
+ void
+ real(_Tp __val) { _M_real = __val; }
+
+ void
+ imag(_Tp __val) { _M_imag = __val; }
+
+ /// Assign this complex number to scalar @a t.
+ complex<_Tp>& operator=(const _Tp&);
+
+ /// Add @a t to this complex number.
+ // 26.2.5/1
+ complex<_Tp>&
+ operator+=(const _Tp& __t)
+ {
+ _M_real += __t;
+ return *this;
+ }
+
+ /// Subtract @a t from this complex number.
+ // 26.2.5/3
+ complex<_Tp>&
+ operator-=(const _Tp& __t)
+ {
+ _M_real -= __t;
+ return *this;
+ }
+
+ /// Multiply this complex number by @a t.
+ complex<_Tp>& operator*=(const _Tp&);
+ /// Divide this complex number by @a t.
+ complex<_Tp>& operator/=(const _Tp&);
+
+ // Lets the compiler synthesize the
+ // copy and assignment operator
+ // complex<_Tp>& operator= (const complex<_Tp>&);
+ /// Assign this complex number to complex @a z.
+ template<typename _Up>
+ complex<_Tp>& operator=(const complex<_Up>&);
+ /// Add @a z to this complex number.
+ template<typename _Up>
+ complex<_Tp>& operator+=(const complex<_Up>&);
+ /// Subtract @a z from this complex number.
+ template<typename _Up>
+ complex<_Tp>& operator-=(const complex<_Up>&);
+ /// Multiply this complex number by @a z.
+ template<typename _Up>
+ complex<_Tp>& operator*=(const complex<_Up>&);
+ /// Divide this complex number by @a z.
+ template<typename _Up>
+ complex<_Tp>& operator/=(const complex<_Up>&);
+
+ _GLIBCXX_USE_CONSTEXPR complex __rep() const
+ { return *this; }
+
+ private:
+ _Tp _M_real;
+ _Tp _M_imag;
+ };
+
+ template<typename _Tp>
+ complex<_Tp>&
+ complex<_Tp>::operator=(const _Tp& __t)
+ {
+ _M_real = __t;
+ _M_imag = _Tp();
+ return *this;
+ }
+
+ // 26.2.5/5
+ template<typename _Tp>
+ complex<_Tp>&
+ complex<_Tp>::operator*=(const _Tp& __t)
+ {
+ _M_real *= __t;
+ _M_imag *= __t;
+ return *this;
+ }
+
+ // 26.2.5/7
+ template<typename _Tp>
+ complex<_Tp>&
+ complex<_Tp>::operator/=(const _Tp& __t)
+ {
+ _M_real /= __t;
+ _M_imag /= __t;
+ return *this;
+ }
+
+ template<typename _Tp>
+ template<typename _Up>
+ complex<_Tp>&
+ complex<_Tp>::operator=(const complex<_Up>& __z)
+ {
+ _M_real = __z.real();
+ _M_imag = __z.imag();
+ return *this;
+ }
+
+ // 26.2.5/9
+ template<typename _Tp>
+ template<typename _Up>
+ complex<_Tp>&
+ complex<_Tp>::operator+=(const complex<_Up>& __z)
+ {
+ _M_real += __z.real();
+ _M_imag += __z.imag();
+ return *this;
+ }
+
+ // 26.2.5/11
+ template<typename _Tp>
+ template<typename _Up>
+ complex<_Tp>&
+ complex<_Tp>::operator-=(const complex<_Up>& __z)
+ {
+ _M_real -= __z.real();
+ _M_imag -= __z.imag();
+ return *this;
+ }
+
+ // 26.2.5/13
+ // XXX: This is a grammar school implementation.
+ template<typename _Tp>
+ template<typename _Up>
+ complex<_Tp>&
+ complex<_Tp>::operator*=(const complex<_Up>& __z)
+ {
+ const _Tp __r = _M_real * __z.real() - _M_imag * __z.imag();
+ _M_imag = _M_real * __z.imag() + _M_imag * __z.real();
+ _M_real = __r;
+ return *this;
+ }
+
+ // 26.2.5/15
+ // XXX: This is a grammar school implementation.
+ template<typename _Tp>
+ template<typename _Up>
+ complex<_Tp>&
+ complex<_Tp>::operator/=(const complex<_Up>& __z)
+ {
+ const _Tp __r = _M_real * __z.real() + _M_imag * __z.imag();
+ const _Tp __n = std::norm(__z);
+ _M_imag = (_M_imag * __z.real() - _M_real * __z.imag()) / __n;
+ _M_real = __r / __n;
+ return *this;
+ }
+
+ // Operators:
+ //@{
+ /// Return new complex value @a x plus @a y.
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator+(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ {
+ complex<_Tp> __r = __x;
+ __r += __y;
+ return __r;
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator+(const complex<_Tp>& __x, const _Tp& __y)
+ {
+ complex<_Tp> __r = __x;
+ __r += __y;
+ return __r;
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator+(const _Tp& __x, const complex<_Tp>& __y)
+ {
+ complex<_Tp> __r = __y;
+ __r += __x;
+ return __r;
+ }
+ //@}
+
+ //@{
+ /// Return new complex value @a x minus @a y.
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ {
+ complex<_Tp> __r = __x;
+ __r -= __y;
+ return __r;
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator-(const complex<_Tp>& __x, const _Tp& __y)
+ {
+ complex<_Tp> __r = __x;
+ __r -= __y;
+ return __r;
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator-(const _Tp& __x, const complex<_Tp>& __y)
+ {
+ complex<_Tp> __r(__x, -__y.imag());
+ __r -= __y.real();
+ return __r;
+ }
+ //@}
+
+ //@{
+ /// Return new complex value @a x times @a y.
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ {
+ complex<_Tp> __r = __x;
+ __r *= __y;
+ return __r;
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator*(const complex<_Tp>& __x, const _Tp& __y)
+ {
+ complex<_Tp> __r = __x;
+ __r *= __y;
+ return __r;
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator*(const _Tp& __x, const complex<_Tp>& __y)
+ {
+ complex<_Tp> __r = __y;
+ __r *= __x;
+ return __r;
+ }
+ //@}
+
+ //@{
+ /// Return new complex value @a x divided by @a y.
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator/(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ {
+ complex<_Tp> __r = __x;
+ __r /= __y;
+ return __r;
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator/(const complex<_Tp>& __x, const _Tp& __y)
+ {
+ complex<_Tp> __r = __x;
+ __r /= __y;
+ return __r;
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator/(const _Tp& __x, const complex<_Tp>& __y)
+ {
+ complex<_Tp> __r = __x;
+ __r /= __y;
+ return __r;
+ }
+ //@}
+
+ /// Return @a x.
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator+(const complex<_Tp>& __x)
+ { return __x; }
+
+ /// Return complex negation of @a x.
+ template<typename _Tp>
+ inline complex<_Tp>
+ operator-(const complex<_Tp>& __x)
+ { return complex<_Tp>(-__x.real(), -__x.imag()); }
+
+ //@{
+ /// Return true if @a x is equal to @a y.
+ template<typename _Tp>
+ inline _GLIBCXX_CONSTEXPR bool
+ operator==(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ { return __x.real() == __y.real() && __x.imag() == __y.imag(); }
+
+ template<typename _Tp>
+ inline _GLIBCXX_CONSTEXPR bool
+ operator==(const complex<_Tp>& __x, const _Tp& __y)
+ { return __x.real() == __y && __x.imag() == _Tp(); }
+
+ template<typename _Tp>
+ inline _GLIBCXX_CONSTEXPR bool
+ operator==(const _Tp& __x, const complex<_Tp>& __y)
+ { return __x == __y.real() && _Tp() == __y.imag(); }
+ //@}
+
+ //@{
+ /// Return false if @a x is equal to @a y.
+ template<typename _Tp>
+ inline _GLIBCXX_CONSTEXPR bool
+ operator!=(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ { return __x.real() != __y.real() || __x.imag() != __y.imag(); }
+
+ template<typename _Tp>
+ inline _GLIBCXX_CONSTEXPR bool
+ operator!=(const complex<_Tp>& __x, const _Tp& __y)
+ { return __x.real() != __y || __x.imag() != _Tp(); }
+
+ template<typename _Tp>
+ inline _GLIBCXX_CONSTEXPR bool
+ operator!=(const _Tp& __x, const complex<_Tp>& __y)
+ { return __x != __y.real() || _Tp() != __y.imag(); }
+ //@}
+
+ /// Extraction operator for complex values.
+ template<typename _Tp, typename _CharT, class _Traits>
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
+ {
+ _Tp __re_x, __im_x;
+ _CharT __ch;
+ __is >> __ch;
+ if (__ch == '(')
+ {
+ __is >> __re_x >> __ch;
+ if (__ch == ',')
+ {
+ __is >> __im_x >> __ch;
+ if (__ch == ')')
+ __x = complex<_Tp>(__re_x, __im_x);
+ else
+ __is.setstate(ios_base::failbit);
+ }
+ else if (__ch == ')')
+ __x = __re_x;
+ else
+ __is.setstate(ios_base::failbit);
+ }
+ else
+ {
+ __is.putback(__ch);
+ __is >> __re_x;
+ __x = __re_x;
+ }
+ return __is;
+ }
+
+ /// Insertion operator for complex values.
+ template<typename _Tp, typename _CharT, class _Traits>
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
+ {
+ basic_ostringstream<_CharT, _Traits> __s;
+ __s.flags(__os.flags());
+ __s.imbue(__os.getloc());
+ __s.precision(__os.precision());
+ __s << '(' << __x.real() << ',' << __x.imag() << ')';
+ return __os << __s.str();
+ }
+
+ // Values
+#if __cplusplus >= 201103L
+ template<typename _Tp>
+ constexpr _Tp
+ real(const complex<_Tp>& __z)
+ { return __z.real(); }
+
+ template<typename _Tp>
+ constexpr _Tp
+ imag(const complex<_Tp>& __z)
+ { return __z.imag(); }
+#else
+ template<typename _Tp>
+ inline _Tp&
+ real(complex<_Tp>& __z)
+ { return __z.real(); }
+
+ template<typename _Tp>
+ inline const _Tp&
+ real(const complex<_Tp>& __z)
+ { return __z.real(); }
+
+ template<typename _Tp>
+ inline _Tp&
+ imag(complex<_Tp>& __z)
+ { return __z.imag(); }
+
+ template<typename _Tp>
+ inline const _Tp&
+ imag(const complex<_Tp>& __z)
+ { return __z.imag(); }
+#endif
+
+ // 26.2.7/3 abs(__z): Returns the magnitude of __z.
+ template<typename _Tp>
+ inline _Tp
+ __complex_abs(const complex<_Tp>& __z)
+ {
+ _Tp __x = __z.real();
+ _Tp __y = __z.imag();
+ const _Tp __s = std::max(abs(__x), abs(__y));
+ if (__s == _Tp()) // well ...
+ return __s;
+ __x /= __s;
+ __y /= __s;
+ return __s * sqrt(__x * __x + __y * __y);
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline float
+ __complex_abs(__complex__ float __z) { return __builtin_cabsf(__z); }
+
+ inline double
+ __complex_abs(__complex__ double __z) { return __builtin_cabs(__z); }
+
+ inline long double
+ __complex_abs(const __complex__ long double& __z)
+ { return __builtin_cabsl(__z); }
+
+ template<typename _Tp>
+ inline _Tp
+ abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline _Tp
+ abs(const complex<_Tp>& __z) { return __complex_abs(__z); }
+#endif
+
+
+ // 26.2.7/4: arg(__z): Returns the phase angle of __z.
+ template<typename _Tp>
+ inline _Tp
+ __complex_arg(const complex<_Tp>& __z)
+ { return atan2(__z.imag(), __z.real()); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline float
+ __complex_arg(__complex__ float __z) { return __builtin_cargf(__z); }
+
+ inline double
+ __complex_arg(__complex__ double __z) { return __builtin_carg(__z); }
+
+ inline long double
+ __complex_arg(const __complex__ long double& __z)
+ { return __builtin_cargl(__z); }
+
+ template<typename _Tp>
+ inline _Tp
+ arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline _Tp
+ arg(const complex<_Tp>& __z) { return __complex_arg(__z); }
+#endif
+
+ // 26.2.7/5: norm(__z) returns the squared magnitude of __z.
+ // As defined, norm() is -not- a norm is the common mathematical
+ // sens used in numerics. The helper class _Norm_helper<> tries to
+ // distinguish between builtin floating point and the rest, so as
+ // to deliver an answer as close as possible to the real value.
+ template<bool>
+ struct _Norm_helper
+ {
+ template<typename _Tp>
+ static inline _Tp _S_do_it(const complex<_Tp>& __z)
+ {
+ const _Tp __x = __z.real();
+ const _Tp __y = __z.imag();
+ return __x * __x + __y * __y;
+ }
+ };
+
+ template<>
+ struct _Norm_helper<true>
+ {
+ template<typename _Tp>
+ static inline _Tp _S_do_it(const complex<_Tp>& __z)
+ {
+ _Tp __res = std::abs(__z);
+ return __res * __res;
+ }
+ };
+
+ template<typename _Tp>
+ inline _Tp
+ norm(const complex<_Tp>& __z)
+ {
+ return _Norm_helper<__is_floating<_Tp>::__value
+ && !_GLIBCXX_FAST_MATH>::_S_do_it(__z);
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ polar(const _Tp& __rho, const _Tp& __theta)
+ { return complex<_Tp>(__rho * cos(__theta), __rho * sin(__theta)); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ conj(const complex<_Tp>& __z)
+ { return complex<_Tp>(__z.real(), -__z.imag()); }
+
+ // Transcendentals
+
+ // 26.2.8/1 cos(__z): Returns the cosine of __z.
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_cos(const complex<_Tp>& __z)
+ {
+ const _Tp __x = __z.real();
+ const _Tp __y = __z.imag();
+ return complex<_Tp>(cos(__x) * cosh(__y), -sin(__x) * sinh(__y));
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_cos(__complex__ float __z) { return __builtin_ccosf(__z); }
+
+ inline __complex__ double
+ __complex_cos(__complex__ double __z) { return __builtin_ccos(__z); }
+
+ inline __complex__ long double
+ __complex_cos(const __complex__ long double& __z)
+ { return __builtin_ccosl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ cos(const complex<_Tp>& __z) { return __complex_cos(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ cos(const complex<_Tp>& __z) { return __complex_cos(__z); }
+#endif
+
+ // 26.2.8/2 cosh(__z): Returns the hyperbolic cosine of __z.
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_cosh(const complex<_Tp>& __z)
+ {
+ const _Tp __x = __z.real();
+ const _Tp __y = __z.imag();
+ return complex<_Tp>(cosh(__x) * cos(__y), sinh(__x) * sin(__y));
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_cosh(__complex__ float __z) { return __builtin_ccoshf(__z); }
+
+ inline __complex__ double
+ __complex_cosh(__complex__ double __z) { return __builtin_ccosh(__z); }
+
+ inline __complex__ long double
+ __complex_cosh(const __complex__ long double& __z)
+ { return __builtin_ccoshl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ cosh(const complex<_Tp>& __z) { return __complex_cosh(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ cosh(const complex<_Tp>& __z) { return __complex_cosh(__z); }
+#endif
+
+ // 26.2.8/3 exp(__z): Returns the complex base e exponential of x
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_exp(const complex<_Tp>& __z)
+ { return std::polar(exp(__z.real()), __z.imag()); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_exp(__complex__ float __z) { return __builtin_cexpf(__z); }
+
+ inline __complex__ double
+ __complex_exp(__complex__ double __z) { return __builtin_cexp(__z); }
+
+ inline __complex__ long double
+ __complex_exp(const __complex__ long double& __z)
+ { return __builtin_cexpl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ exp(const complex<_Tp>& __z) { return __complex_exp(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ exp(const complex<_Tp>& __z) { return __complex_exp(__z); }
+#endif
+
+ // 26.2.8/5 log(__z): Returns the natural complex logarithm of __z.
+ // The branch cut is along the negative axis.
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_log(const complex<_Tp>& __z)
+ { return complex<_Tp>(log(std::abs(__z)), std::arg(__z)); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_log(__complex__ float __z) { return __builtin_clogf(__z); }
+
+ inline __complex__ double
+ __complex_log(__complex__ double __z) { return __builtin_clog(__z); }
+
+ inline __complex__ long double
+ __complex_log(const __complex__ long double& __z)
+ { return __builtin_clogl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ log(const complex<_Tp>& __z) { return __complex_log(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ log(const complex<_Tp>& __z) { return __complex_log(__z); }
+#endif
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ log10(const complex<_Tp>& __z)
+ { return std::log(__z) / log(_Tp(10.0)); }
+
+ // 26.2.8/10 sin(__z): Returns the sine of __z.
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_sin(const complex<_Tp>& __z)
+ {
+ const _Tp __x = __z.real();
+ const _Tp __y = __z.imag();
+ return complex<_Tp>(sin(__x) * cosh(__y), cos(__x) * sinh(__y));
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_sin(__complex__ float __z) { return __builtin_csinf(__z); }
+
+ inline __complex__ double
+ __complex_sin(__complex__ double __z) { return __builtin_csin(__z); }
+
+ inline __complex__ long double
+ __complex_sin(const __complex__ long double& __z)
+ { return __builtin_csinl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ sin(const complex<_Tp>& __z) { return __complex_sin(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ sin(const complex<_Tp>& __z) { return __complex_sin(__z); }
+#endif
+
+ // 26.2.8/11 sinh(__z): Returns the hyperbolic sine of __z.
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_sinh(const complex<_Tp>& __z)
+ {
+ const _Tp __x = __z.real();
+ const _Tp __y = __z.imag();
+ return complex<_Tp>(sinh(__x) * cos(__y), cosh(__x) * sin(__y));
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_sinh(__complex__ float __z) { return __builtin_csinhf(__z); }
+
+ inline __complex__ double
+ __complex_sinh(__complex__ double __z) { return __builtin_csinh(__z); }
+
+ inline __complex__ long double
+ __complex_sinh(const __complex__ long double& __z)
+ { return __builtin_csinhl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ sinh(const complex<_Tp>& __z) { return __complex_sinh(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ sinh(const complex<_Tp>& __z) { return __complex_sinh(__z); }
+#endif
+
+ // 26.2.8/13 sqrt(__z): Returns the complex square root of __z.
+ // The branch cut is on the negative axis.
+ template<typename _Tp>
+ complex<_Tp>
+ __complex_sqrt(const complex<_Tp>& __z)
+ {
+ _Tp __x = __z.real();
+ _Tp __y = __z.imag();
+
+ if (__x == _Tp())
+ {
+ _Tp __t = sqrt(abs(__y) / 2);
+ return complex<_Tp>(__t, __y < _Tp() ? -__t : __t);
+ }
+ else
+ {
+ _Tp __t = sqrt(2 * (std::abs(__z) + abs(__x)));
+ _Tp __u = __t / 2;
+ return __x > _Tp()
+ ? complex<_Tp>(__u, __y / __t)
+ : complex<_Tp>(abs(__y) / __t, __y < _Tp() ? -__u : __u);
+ }
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_sqrt(__complex__ float __z) { return __builtin_csqrtf(__z); }
+
+ inline __complex__ double
+ __complex_sqrt(__complex__ double __z) { return __builtin_csqrt(__z); }
+
+ inline __complex__ long double
+ __complex_sqrt(const __complex__ long double& __z)
+ { return __builtin_csqrtl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ sqrt(const complex<_Tp>& __z) { return __complex_sqrt(__z); }
+#endif
+
+ // 26.2.8/14 tan(__z): Return the complex tangent of __z.
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_tan(const complex<_Tp>& __z)
+ { return std::sin(__z) / std::cos(__z); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_tan(__complex__ float __z) { return __builtin_ctanf(__z); }
+
+ inline __complex__ double
+ __complex_tan(__complex__ double __z) { return __builtin_ctan(__z); }
+
+ inline __complex__ long double
+ __complex_tan(const __complex__ long double& __z)
+ { return __builtin_ctanl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ tan(const complex<_Tp>& __z) { return __complex_tan(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ tan(const complex<_Tp>& __z) { return __complex_tan(__z); }
+#endif
+
+
+ // 26.2.8/15 tanh(__z): Returns the hyperbolic tangent of __z.
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_tanh(const complex<_Tp>& __z)
+ { return std::sinh(__z) / std::cosh(__z); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_tanh(__complex__ float __z) { return __builtin_ctanhf(__z); }
+
+ inline __complex__ double
+ __complex_tanh(__complex__ double __z) { return __builtin_ctanh(__z); }
+
+ inline __complex__ long double
+ __complex_tanh(const __complex__ long double& __z)
+ { return __builtin_ctanhl(__z); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ tanh(const complex<_Tp>& __z) { return __complex_tanh(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ tanh(const complex<_Tp>& __z) { return __complex_tanh(__z); }
+#endif
+
+
+ // 26.2.8/9 pow(__x, __y): Returns the complex power base of __x
+ // raised to the __y-th power. The branch
+ // cut is on the negative axis.
+ template<typename _Tp>
+ complex<_Tp>
+ __complex_pow_unsigned(complex<_Tp> __x, unsigned __n)
+ {
+ complex<_Tp> __y = __n % 2 ? __x : complex<_Tp>(1);
+
+ while (__n >>= 1)
+ {
+ __x *= __x;
+ if (__n % 2)
+ __y *= __x;
+ }
+
+ return __y;
+ }
+
+ // In C++11 mode we used to implement the resolution of
+ // DR 844. complex pow return type is ambiguous.
+ // thus the following overload was disabled in that mode. However, doing
+ // that causes all sorts of issues, see, for example:
+ // http://gcc.gnu.org/ml/libstdc++/2013-01/msg00058.html
+ // and also PR57974.
+ template<typename _Tp>
+ inline complex<_Tp>
+ pow(const complex<_Tp>& __z, int __n)
+ {
+ return __n < 0
+ ? complex<_Tp>(1) / std::__complex_pow_unsigned(__z, -(unsigned)__n)
+ : std::__complex_pow_unsigned(__z, __n);
+ }
+
+ template<typename _Tp>
+ complex<_Tp>
+ pow(const complex<_Tp>& __x, const _Tp& __y)
+ {
+#ifndef _GLIBCXX_USE_C99_COMPLEX
+ if (__x == _Tp())
+ return _Tp();
+#endif
+ if (__x.imag() == _Tp() && __x.real() > _Tp())
+ return pow(__x.real(), __y);
+
+ complex<_Tp> __t = std::log(__x);
+ return std::polar(exp(__y * __t.real()), __y * __t.imag());
+ }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ __complex_pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ { return __x == _Tp() ? _Tp() : std::exp(__y * std::log(__x)); }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_pow(__complex__ float __x, __complex__ float __y)
+ { return __builtin_cpowf(__x, __y); }
+
+ inline __complex__ double
+ __complex_pow(__complex__ double __x, __complex__ double __y)
+ { return __builtin_cpow(__x, __y); }
+
+ inline __complex__ long double
+ __complex_pow(const __complex__ long double& __x,
+ const __complex__ long double& __y)
+ { return __builtin_cpowl(__x, __y); }
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ { return __complex_pow(__x.__rep(), __y.__rep()); }
+#else
+ template<typename _Tp>
+ inline complex<_Tp>
+ pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
+ { return __complex_pow(__x, __y); }
+#endif
+
+ template<typename _Tp>
+ inline complex<_Tp>
+ pow(const _Tp& __x, const complex<_Tp>& __y)
+ {
+ return __x > _Tp() ? std::polar(pow(__x, __y.real()),
+ __y.imag() * log(__x))
+ : std::pow(complex<_Tp>(__x), __y);
+ }
+
+ /// 26.2.3 complex specializations
+ /// complex<float> specialization
+ template<>
+ struct complex<float>
+ {
+ typedef float value_type;
+ typedef __complex__ float _ComplexT;
+
+ _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { }
+
+ _GLIBCXX_CONSTEXPR complex(float __r = 0.0f, float __i = 0.0f)
+#if __cplusplus >= 201103L
+ : _M_value{ __r, __i } { }
+#else
+ {
+ __real__ _M_value = __r;
+ __imag__ _M_value = __i;
+ }
+#endif
+
+ explicit _GLIBCXX_CONSTEXPR complex(const complex<double>&);
+ explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&);
+
+#if __cplusplus >= 201103L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 387. std::complex over-encapsulated.
+ __attribute ((__abi_tag__ ("cxx11")))
+ constexpr float
+ real() const { return __real__ _M_value; }
+
+ __attribute ((__abi_tag__ ("cxx11")))
+ constexpr float
+ imag() const { return __imag__ _M_value; }
+#else
+ float&
+ real() { return __real__ _M_value; }
+
+ const float&
+ real() const { return __real__ _M_value; }
+
+ float&
+ imag() { return __imag__ _M_value; }
+
+ const float&
+ imag() const { return __imag__ _M_value; }
+#endif
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 387. std::complex over-encapsulated.
+ void
+ real(float __val) { __real__ _M_value = __val; }
+
+ void
+ imag(float __val) { __imag__ _M_value = __val; }
+
+ complex&
+ operator=(float __f)
+ {
+ _M_value = __f;
+ return *this;
+ }
+
+ complex&
+ operator+=(float __f)
+ {
+ _M_value += __f;
+ return *this;
+ }
+
+ complex&
+ operator-=(float __f)
+ {
+ _M_value -= __f;
+ return *this;
+ }
+
+ complex&
+ operator*=(float __f)
+ {
+ _M_value *= __f;
+ return *this;
+ }
+
+ complex&
+ operator/=(float __f)
+ {
+ _M_value /= __f;
+ return *this;
+ }
+
+ // Let the compiler synthesize the copy and assignment
+ // operator. It always does a pretty good job.
+ // complex& operator=(const complex&);
+
+ template<typename _Tp>
+ complex&
+ operator=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value = __z.real();
+ __imag__ _M_value = __z.imag();
+ return *this;
+ }
+
+ template<typename _Tp>
+ complex&
+ operator+=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value += __z.real();
+ __imag__ _M_value += __z.imag();
+ return *this;
+ }
+
+ template<class _Tp>
+ complex&
+ operator-=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value -= __z.real();
+ __imag__ _M_value -= __z.imag();
+ return *this;
+ }
+
+ template<class _Tp>
+ complex&
+ operator*=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value *= __t;
+ return *this;
+ }
+
+ template<class _Tp>
+ complex&
+ operator/=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value /= __t;
+ return *this;
+ }
+
+ _GLIBCXX_USE_CONSTEXPR _ComplexT __rep() const { return _M_value; }
+
+ private:
+ _ComplexT _M_value;
+ };
+
+ /// 26.2.3 complex specializations
+ /// complex<double> specialization
+ template<>
+ struct complex<double>
+ {
+ typedef double value_type;
+ typedef __complex__ double _ComplexT;
+
+ _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { }
+
+ _GLIBCXX_CONSTEXPR complex(double __r = 0.0, double __i = 0.0)
+#if __cplusplus >= 201103L
+ : _M_value{ __r, __i } { }
+#else
+ {
+ __real__ _M_value = __r;
+ __imag__ _M_value = __i;
+ }
+#endif
+
+ _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
+ : _M_value(__z.__rep()) { }
+
+ explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&);
+
+#if __cplusplus >= 201103L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 387. std::complex over-encapsulated.
+ __attribute ((__abi_tag__ ("cxx11")))
+ constexpr double
+ real() const { return __real__ _M_value; }
+
+ __attribute ((__abi_tag__ ("cxx11")))
+ constexpr double
+ imag() const { return __imag__ _M_value; }
+#else
+ double&
+ real() { return __real__ _M_value; }
+
+ const double&
+ real() const { return __real__ _M_value; }
+
+ double&
+ imag() { return __imag__ _M_value; }
+
+ const double&
+ imag() const { return __imag__ _M_value; }
+#endif
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 387. std::complex over-encapsulated.
+ void
+ real(double __val) { __real__ _M_value = __val; }
+
+ void
+ imag(double __val) { __imag__ _M_value = __val; }
+
+ complex&
+ operator=(double __d)
+ {
+ _M_value = __d;
+ return *this;
+ }
+
+ complex&
+ operator+=(double __d)
+ {
+ _M_value += __d;
+ return *this;
+ }
+
+ complex&
+ operator-=(double __d)
+ {
+ _M_value -= __d;
+ return *this;
+ }
+
+ complex&
+ operator*=(double __d)
+ {
+ _M_value *= __d;
+ return *this;
+ }
+
+ complex&
+ operator/=(double __d)
+ {
+ _M_value /= __d;
+ return *this;
+ }
+
+ // The compiler will synthesize this, efficiently.
+ // complex& operator=(const complex&);
+
+ template<typename _Tp>
+ complex&
+ operator=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value = __z.real();
+ __imag__ _M_value = __z.imag();
+ return *this;
+ }
+
+ template<typename _Tp>
+ complex&
+ operator+=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value += __z.real();
+ __imag__ _M_value += __z.imag();
+ return *this;
+ }
+
+ template<typename _Tp>
+ complex&
+ operator-=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value -= __z.real();
+ __imag__ _M_value -= __z.imag();
+ return *this;
+ }
+
+ template<typename _Tp>
+ complex&
+ operator*=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value *= __t;
+ return *this;
+ }
+
+ template<typename _Tp>
+ complex&
+ operator/=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value /= __t;
+ return *this;
+ }
+
+ _GLIBCXX_USE_CONSTEXPR _ComplexT __rep() const { return _M_value; }
+
+ private:
+ _ComplexT _M_value;
+ };
+
+ /// 26.2.3 complex specializations
+ /// complex<long double> specialization
+ template<>
+ struct complex<long double>
+ {
+ typedef long double value_type;
+ typedef __complex__ long double _ComplexT;
+
+ _GLIBCXX_CONSTEXPR complex(_ComplexT __z) : _M_value(__z) { }
+
+ _GLIBCXX_CONSTEXPR complex(long double __r = 0.0L,
+ long double __i = 0.0L)
+#if __cplusplus >= 201103L
+ : _M_value{ __r, __i } { }
+#else
+ {
+ __real__ _M_value = __r;
+ __imag__ _M_value = __i;
+ }
+#endif
+
+ _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
+ : _M_value(__z.__rep()) { }
+
+ _GLIBCXX_CONSTEXPR complex(const complex<double>& __z)
+ : _M_value(__z.__rep()) { }
+
+#if __cplusplus >= 201103L
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 387. std::complex over-encapsulated.
+ __attribute ((__abi_tag__ ("cxx11")))
+ constexpr long double
+ real() const { return __real__ _M_value; }
+
+ __attribute ((__abi_tag__ ("cxx11")))
+ constexpr long double
+ imag() const { return __imag__ _M_value; }
+#else
+ long double&
+ real() { return __real__ _M_value; }
+
+ const long double&
+ real() const { return __real__ _M_value; }
+
+ long double&
+ imag() { return __imag__ _M_value; }
+
+ const long double&
+ imag() const { return __imag__ _M_value; }
+#endif
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 387. std::complex over-encapsulated.
+ void
+ real(long double __val) { __real__ _M_value = __val; }
+
+ void
+ imag(long double __val) { __imag__ _M_value = __val; }
+
+ complex&
+ operator=(long double __r)
+ {
+ _M_value = __r;
+ return *this;
+ }
+
+ complex&
+ operator+=(long double __r)
+ {
+ _M_value += __r;
+ return *this;
+ }
+
+ complex&
+ operator-=(long double __r)
+ {
+ _M_value -= __r;
+ return *this;
+ }
+
+ complex&
+ operator*=(long double __r)
+ {
+ _M_value *= __r;
+ return *this;
+ }
+
+ complex&
+ operator/=(long double __r)
+ {
+ _M_value /= __r;
+ return *this;
+ }
+
+ // The compiler knows how to do this efficiently
+ // complex& operator=(const complex&);
+
+ template<typename _Tp>
+ complex&
+ operator=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value = __z.real();
+ __imag__ _M_value = __z.imag();
+ return *this;
+ }
+
+ template<typename _Tp>
+ complex&
+ operator+=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value += __z.real();
+ __imag__ _M_value += __z.imag();
+ return *this;
+ }
+
+ template<typename _Tp>
+ complex&
+ operator-=(const complex<_Tp>& __z)
+ {
+ __real__ _M_value -= __z.real();
+ __imag__ _M_value -= __z.imag();
+ return *this;
+ }
+
+ template<typename _Tp>
+ complex&
+ operator*=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value *= __t;
+ return *this;
+ }
+
+ template<typename _Tp>
+ complex&
+ operator/=(const complex<_Tp>& __z)
+ {
+ _ComplexT __t;
+ __real__ __t = __z.real();
+ __imag__ __t = __z.imag();
+ _M_value /= __t;
+ return *this;
+ }
+
+ _GLIBCXX_USE_CONSTEXPR _ComplexT __rep() const { return _M_value; }
+
+ private:
+ _ComplexT _M_value;
+ };
+
+ // These bits have to be at the end of this file, so that the
+ // specializations have all been defined.
+ inline _GLIBCXX_CONSTEXPR
+ complex<float>::complex(const complex<double>& __z)
+ : _M_value(__z.__rep()) { }
+
+ inline _GLIBCXX_CONSTEXPR
+ complex<float>::complex(const complex<long double>& __z)
+ : _M_value(__z.__rep()) { }
+
+ inline _GLIBCXX_CONSTEXPR
+ complex<double>::complex(const complex<long double>& __z)
+ : _M_value(__z.__rep()) { }
+
+ // Inhibit implicit instantiations for required instantiations,
+ // which are defined via explicit instantiations elsewhere.
+ // NB: This syntax is a GNU extension.
+#if _GLIBCXX_EXTERN_TEMPLATE
+ extern template istream& operator>>(istream&, complex<float>&);
+ extern template ostream& operator<<(ostream&, const complex<float>&);
+ extern template istream& operator>>(istream&, complex<double>&);
+ extern template ostream& operator<<(ostream&, const complex<double>&);
+ extern template istream& operator>>(istream&, complex<long double>&);
+ extern template ostream& operator<<(ostream&, const complex<long double>&);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ extern template wistream& operator>>(wistream&, complex<float>&);
+ extern template wostream& operator<<(wostream&, const complex<float>&);
+ extern template wistream& operator>>(wistream&, complex<double>&);
+ extern template wostream& operator<<(wostream&, const complex<double>&);
+ extern template wistream& operator>>(wistream&, complex<long double>&);
+ extern template wostream& operator<<(wostream&, const complex<long double>&);
+#endif
+#endif
+
+ // @} group complex_numbers
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // See ext/type_traits.h for the primary template.
+ template<typename _Tp, typename _Up>
+ struct __promote_2<std::complex<_Tp>, _Up>
+ {
+ public:
+ typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type;
+ };
+
+ template<typename _Tp, typename _Up>
+ struct __promote_2<_Tp, std::complex<_Up> >
+ {
+ public:
+ typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type;
+ };
+
+ template<typename _Tp, typename _Up>
+ struct __promote_2<std::complex<_Tp>, std::complex<_Up> >
+ {
+ public:
+ typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type;
+ };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#if __cplusplus >= 201103L
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // Forward declarations.
+ template<typename _Tp> std::complex<_Tp> acos(const std::complex<_Tp>&);
+ template<typename _Tp> std::complex<_Tp> asin(const std::complex<_Tp>&);
+ template<typename _Tp> std::complex<_Tp> atan(const std::complex<_Tp>&);
+
+ template<typename _Tp> std::complex<_Tp> acosh(const std::complex<_Tp>&);
+ template<typename _Tp> std::complex<_Tp> asinh(const std::complex<_Tp>&);
+ template<typename _Tp> std::complex<_Tp> atanh(const std::complex<_Tp>&);
+ // DR 595.
+ template<typename _Tp> _Tp fabs(const std::complex<_Tp>&);
+
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ __complex_acos(const std::complex<_Tp>& __z)
+ {
+ const std::complex<_Tp> __t = std::asin(__z);
+ const _Tp __pi_2 = 1.5707963267948966192313216916397514L;
+ return std::complex<_Tp>(__pi_2 - __t.real(), -__t.imag());
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
+ inline __complex__ float
+ __complex_acos(__complex__ float __z)
+ { return __builtin_cacosf(__z); }
+
+ inline __complex__ double
+ __complex_acos(__complex__ double __z)
+ { return __builtin_cacos(__z); }
+
+ inline __complex__ long double
+ __complex_acos(const __complex__ long double& __z)
+ { return __builtin_cacosl(__z); }
+
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ acos(const std::complex<_Tp>& __z)
+ { return __complex_acos(__z.__rep()); }
+#else
+ /// acos(__z) [8.1.2].
+ // Effects: Behaves the same as C99 function cacos, defined
+ // in subclause 7.3.5.1.
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ acos(const std::complex<_Tp>& __z)
+ { return __complex_acos(__z); }
+#endif
+
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ __complex_asin(const std::complex<_Tp>& __z)
+ {
+ std::complex<_Tp> __t(-__z.imag(), __z.real());
+ __t = std::asinh(__t);
+ return std::complex<_Tp>(__t.imag(), -__t.real());
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
+ inline __complex__ float
+ __complex_asin(__complex__ float __z)
+ { return __builtin_casinf(__z); }
+
+ inline __complex__ double
+ __complex_asin(__complex__ double __z)
+ { return __builtin_casin(__z); }
+
+ inline __complex__ long double
+ __complex_asin(const __complex__ long double& __z)
+ { return __builtin_casinl(__z); }
+
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ asin(const std::complex<_Tp>& __z)
+ { return __complex_asin(__z.__rep()); }
+#else
+ /// asin(__z) [8.1.3].
+ // Effects: Behaves the same as C99 function casin, defined
+ // in subclause 7.3.5.2.
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ asin(const std::complex<_Tp>& __z)
+ { return __complex_asin(__z); }
+#endif
+
+ template<typename _Tp>
+ std::complex<_Tp>
+ __complex_atan(const std::complex<_Tp>& __z)
+ {
+ const _Tp __r2 = __z.real() * __z.real();
+ const _Tp __x = _Tp(1.0) - __r2 - __z.imag() * __z.imag();
+
+ _Tp __num = __z.imag() + _Tp(1.0);
+ _Tp __den = __z.imag() - _Tp(1.0);
+
+ __num = __r2 + __num * __num;
+ __den = __r2 + __den * __den;
+
+ return std::complex<_Tp>(_Tp(0.5) * atan2(_Tp(2.0) * __z.real(), __x),
+ _Tp(0.25) * log(__num / __den));
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
+ inline __complex__ float
+ __complex_atan(__complex__ float __z)
+ { return __builtin_catanf(__z); }
+
+ inline __complex__ double
+ __complex_atan(__complex__ double __z)
+ { return __builtin_catan(__z); }
+
+ inline __complex__ long double
+ __complex_atan(const __complex__ long double& __z)
+ { return __builtin_catanl(__z); }
+
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ atan(const std::complex<_Tp>& __z)
+ { return __complex_atan(__z.__rep()); }
+#else
+ /// atan(__z) [8.1.4].
+ // Effects: Behaves the same as C99 function catan, defined
+ // in subclause 7.3.5.3.
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ atan(const std::complex<_Tp>& __z)
+ { return __complex_atan(__z); }
+#endif
+
+ template<typename _Tp>
+ std::complex<_Tp>
+ __complex_acosh(const std::complex<_Tp>& __z)
+ {
+ // Kahan's formula.
+ return _Tp(2.0) * std::log(std::sqrt(_Tp(0.5) * (__z + _Tp(1.0)))
+ + std::sqrt(_Tp(0.5) * (__z - _Tp(1.0))));
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
+ inline __complex__ float
+ __complex_acosh(__complex__ float __z)
+ { return __builtin_cacoshf(__z); }
+
+ inline __complex__ double
+ __complex_acosh(__complex__ double __z)
+ { return __builtin_cacosh(__z); }
+
+ inline __complex__ long double
+ __complex_acosh(const __complex__ long double& __z)
+ { return __builtin_cacoshl(__z); }
+
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ acosh(const std::complex<_Tp>& __z)
+ { return __complex_acosh(__z.__rep()); }
+#else
+ /// acosh(__z) [8.1.5].
+ // Effects: Behaves the same as C99 function cacosh, defined
+ // in subclause 7.3.6.1.
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ acosh(const std::complex<_Tp>& __z)
+ { return __complex_acosh(__z); }
+#endif
+
+ template<typename _Tp>
+ std::complex<_Tp>
+ __complex_asinh(const std::complex<_Tp>& __z)
+ {
+ std::complex<_Tp> __t((__z.real() - __z.imag())
+ * (__z.real() + __z.imag()) + _Tp(1.0),
+ _Tp(2.0) * __z.real() * __z.imag());
+ __t = std::sqrt(__t);
+
+ return std::log(__t + __z);
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
+ inline __complex__ float
+ __complex_asinh(__complex__ float __z)
+ { return __builtin_casinhf(__z); }
+
+ inline __complex__ double
+ __complex_asinh(__complex__ double __z)
+ { return __builtin_casinh(__z); }
+
+ inline __complex__ long double
+ __complex_asinh(const __complex__ long double& __z)
+ { return __builtin_casinhl(__z); }
+
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ asinh(const std::complex<_Tp>& __z)
+ { return __complex_asinh(__z.__rep()); }
+#else
+ /// asinh(__z) [8.1.6].
+ // Effects: Behaves the same as C99 function casin, defined
+ // in subclause 7.3.6.2.
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ asinh(const std::complex<_Tp>& __z)
+ { return __complex_asinh(__z); }
+#endif
+
+ template<typename _Tp>
+ std::complex<_Tp>
+ __complex_atanh(const std::complex<_Tp>& __z)
+ {
+ const _Tp __i2 = __z.imag() * __z.imag();
+ const _Tp __x = _Tp(1.0) - __i2 - __z.real() * __z.real();
+
+ _Tp __num = _Tp(1.0) + __z.real();
+ _Tp __den = _Tp(1.0) - __z.real();
+
+ __num = __i2 + __num * __num;
+ __den = __i2 + __den * __den;
+
+ return std::complex<_Tp>(_Tp(0.25) * (log(__num) - log(__den)),
+ _Tp(0.5) * atan2(_Tp(2.0) * __z.imag(), __x));
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX_TR1
+ inline __complex__ float
+ __complex_atanh(__complex__ float __z)
+ { return __builtin_catanhf(__z); }
+
+ inline __complex__ double
+ __complex_atanh(__complex__ double __z)
+ { return __builtin_catanh(__z); }
+
+ inline __complex__ long double
+ __complex_atanh(const __complex__ long double& __z)
+ { return __builtin_catanhl(__z); }
+
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ atanh(const std::complex<_Tp>& __z)
+ { return __complex_atanh(__z.__rep()); }
+#else
+ /// atanh(__z) [8.1.7].
+ // Effects: Behaves the same as C99 function catanh, defined
+ // in subclause 7.3.6.3.
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ atanh(const std::complex<_Tp>& __z)
+ { return __complex_atanh(__z); }
+#endif
+
+ template<typename _Tp>
+ inline _Tp
+ /// fabs(__z) [8.1.8].
+ // Effects: Behaves the same as C99 function cabs, defined
+ // in subclause 7.3.8.1.
+ fabs(const std::complex<_Tp>& __z)
+ { return std::abs(__z); }
+
+ /// Additional overloads [8.1.9].
+ template<typename _Tp>
+ inline typename __gnu_cxx::__promote<_Tp>::__type
+ arg(_Tp __x)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+#if (_GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC)
+ return std::signbit(__x) ? __type(3.1415926535897932384626433832795029L)
+ : __type();
+#else
+ return std::arg(std::complex<__type>(__x));
+#endif
+ }
+
+ template<typename _Tp>
+ inline typename __gnu_cxx::__promote<_Tp>::__type
+ imag(_Tp)
+ { return _Tp(); }
+
+ template<typename _Tp>
+ inline typename __gnu_cxx::__promote<_Tp>::__type
+ norm(_Tp __x)
+ {
+ typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
+ return __type(__x) * __type(__x);
+ }
+
+ template<typename _Tp>
+ inline typename __gnu_cxx::__promote<_Tp>::__type
+ real(_Tp __x)
+ { return __x; }
+
+ template<typename _Tp, typename _Up>
+ inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
+ pow(const std::complex<_Tp>& __x, const _Up& __y)
+ {
+ typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
+ return std::pow(std::complex<__type>(__x), __type(__y));
+ }
+
+ template<typename _Tp, typename _Up>
+ inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
+ pow(const _Tp& __x, const std::complex<_Up>& __y)
+ {
+ typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
+ return std::pow(__type(__x), std::complex<__type>(__y));
+ }
+
+ template<typename _Tp, typename _Up>
+ inline std::complex<typename __gnu_cxx::__promote_2<_Tp, _Up>::__type>
+ pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y)
+ {
+ typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
+ return std::pow(std::complex<__type>(__x),
+ std::complex<__type>(__y));
+ }
+
+ // Forward declarations.
+ // DR 781.
+ template<typename _Tp> std::complex<_Tp> proj(const std::complex<_Tp>&);
+
+ template<typename _Tp>
+ std::complex<_Tp>
+ __complex_proj(const std::complex<_Tp>& __z)
+ {
+ const _Tp __den = (__z.real() * __z.real()
+ + __z.imag() * __z.imag() + _Tp(1.0));
+
+ return std::complex<_Tp>((_Tp(2.0) * __z.real()) / __den,
+ (_Tp(2.0) * __z.imag()) / __den);
+ }
+
+#if _GLIBCXX_USE_C99_COMPLEX
+ inline __complex__ float
+ __complex_proj(__complex__ float __z)
+ { return __builtin_cprojf(__z); }
+
+ inline __complex__ double
+ __complex_proj(__complex__ double __z)
+ { return __builtin_cproj(__z); }
+
+ inline __complex__ long double
+ __complex_proj(const __complex__ long double& __z)
+ { return __builtin_cprojl(__z); }
+
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ proj(const std::complex<_Tp>& __z)
+ { return __complex_proj(__z.__rep()); }
+#else
+ template<typename _Tp>
+ inline std::complex<_Tp>
+ proj(const std::complex<_Tp>& __z)
+ { return __complex_proj(__z); }
+#endif
+
+ // DR 1137.
+ template<typename _Tp>
+ inline typename __gnu_cxx::__promote<_Tp>::__type
+ proj(_Tp __x)
+ { return __x; }
+
+ template<typename _Tp>
+ inline typename __gnu_cxx::__promote<_Tp>::__type
+ conj(_Tp __x)
+ { return __x; }
+
+#if __cplusplus > 201103L
+
+inline namespace literals {
+inline namespace complex_literals {
+
+ constexpr std::complex<float>
+ operator""if(long double __num)
+ { return std::complex<float>{0.0F, static_cast<float>(__num)}; }
+
+ constexpr std::complex<float>
+ operator""if(unsigned long long __num)
+ { return std::complex<float>{0.0F, static_cast<float>(__num)}; }
+
+ constexpr std::complex<double>
+ operator""i(long double __num)
+ { return std::complex<double>{0.0, static_cast<double>(__num)}; }
+
+ constexpr std::complex<double>
+ operator""i(unsigned long long __num)
+ { return std::complex<double>{0.0, static_cast<double>(__num)}; }
+
+ constexpr std::complex<long double>
+ operator""il(long double __num)
+ { return std::complex<long double>{0.0L, __num}; }
+
+ constexpr std::complex<long double>
+ operator""il(unsigned long long __num)
+ { return std::complex<long double>{0.0L, static_cast<long double>(__num)}; }
+
+} // inline namespace complex_literals
+} // inline namespace literals
+
+#endif // C++14
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif // C++11
+
+#endif /* _GLIBCXX_COMPLEX */
diff --git a/gcc-4.9/libstdc++-v3/include/std/condition_variable b/gcc-4.9/libstdc++-v3/include/std/condition_variable
new file mode 100644
index 0000000..fc111dd
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/condition_variable
@@ -0,0 +1,296 @@
+// <condition_variable> -*- C++ -*-
+
+// Copyright (C) 2008-2014 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/condition_variable
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_CONDITION_VARIABLE
+#define _GLIBCXX_CONDITION_VARIABLE 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <chrono>
+#include <mutex>
+#include <ext/concurrence.h>
+#include <bits/alloc_traits.h>
+#include <bits/allocator.h>
+#include <bits/unique_ptr.h>
+#include <bits/shared_ptr.h>
+
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @defgroup condition_variables Condition Variables
+ * @ingroup concurrency
+ *
+ * Classes for condition_variable support.
+ * @{
+ */
+
+ /// cv_status
+ enum class cv_status { no_timeout, timeout };
+
+ /// condition_variable
+ class condition_variable
+ {
+ typedef chrono::system_clock __clock_t;
+ typedef __gthread_cond_t __native_type;
+
+#ifdef __GTHREAD_COND_INIT
+ __native_type _M_cond = __GTHREAD_COND_INIT;
+#else
+ __native_type _M_cond;
+#endif
+
+ public:
+ typedef __native_type* native_handle_type;
+
+ condition_variable() noexcept;
+ ~condition_variable() noexcept;
+
+ condition_variable(const condition_variable&) = delete;
+ condition_variable& operator=(const condition_variable&) = delete;
+
+ void
+ notify_one() noexcept;
+
+ void
+ notify_all() noexcept;
+
+ void
+ wait(unique_lock<mutex>& __lock);
+
+ template<typename _Predicate>
+ void
+ wait(unique_lock<mutex>& __lock, _Predicate __p)
+ {
+ while (!__p())
+ wait(__lock);
+ }
+
+ template<typename _Duration>
+ cv_status
+ wait_until(unique_lock<mutex>& __lock,
+ const chrono::time_point<__clock_t, _Duration>& __atime)
+ { return __wait_until_impl(__lock, __atime); }
+
+ template<typename _Clock, typename _Duration>
+ cv_status
+ wait_until(unique_lock<mutex>& __lock,
+ const chrono::time_point<_Clock, _Duration>& __atime)
+ {
+ // DR 887 - Sync unknown clock to known clock.
+ const typename _Clock::time_point __c_entry = _Clock::now();
+ const __clock_t::time_point __s_entry = __clock_t::now();
+ const auto __delta = __atime - __c_entry;
+ const auto __s_atime = __s_entry + __delta;
+
+ return __wait_until_impl(__lock, __s_atime);
+ }
+
+ template<typename _Clock, typename _Duration, typename _Predicate>
+ bool
+ wait_until(unique_lock<mutex>& __lock,
+ const chrono::time_point<_Clock, _Duration>& __atime,
+ _Predicate __p)
+ {
+ while (!__p())
+ if (wait_until(__lock, __atime) == cv_status::timeout)
+ return __p();
+ return true;
+ }
+
+ template<typename _Rep, typename _Period>
+ cv_status
+ wait_for(unique_lock<mutex>& __lock,
+ const chrono::duration<_Rep, _Period>& __rtime)
+ { return wait_until(__lock, __clock_t::now() + __rtime); }
+
+ template<typename _Rep, typename _Period, typename _Predicate>
+ bool
+ wait_for(unique_lock<mutex>& __lock,
+ const chrono::duration<_Rep, _Period>& __rtime,
+ _Predicate __p)
+ { return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
+
+ native_handle_type
+ native_handle()
+ { return &_M_cond; }
+
+ private:
+ template<typename _Dur>
+ cv_status
+ __wait_until_impl(unique_lock<mutex>& __lock,
+ const chrono::time_point<__clock_t, _Dur>& __atime)
+ {
+ auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
+ auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
+
+ __gthread_time_t __ts =
+ {
+ static_cast<std::time_t>(__s.time_since_epoch().count()),
+ static_cast<long>(__ns.count())
+ };
+
+ __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
+ &__ts);
+
+ return (__clock_t::now() < __atime
+ ? cv_status::no_timeout : cv_status::timeout);
+ }
+ };
+
+ inline namespace _V2 {
+
+ /// condition_variable_any
+ // Like above, but mutex is not required to have try_lock.
+ class condition_variable_any
+ {
+ typedef chrono::system_clock __clock_t;
+ condition_variable _M_cond;
+ shared_ptr<mutex> _M_mutex;
+
+ // scoped unlock - unlocks in ctor, re-locks in dtor
+ template<typename _Lock>
+ struct _Unlock
+ {
+ explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); }
+
+ ~_Unlock() noexcept(false)
+ {
+ if (uncaught_exception())
+ __try { _M_lock.lock(); } __catch(...) { }
+ else
+ _M_lock.lock();
+ }
+
+ _Unlock(const _Unlock&) = delete;
+ _Unlock& operator=(const _Unlock&) = delete;
+
+ _Lock& _M_lock;
+ };
+
+ public:
+ condition_variable_any() : _M_mutex(std::make_shared<mutex>()) { }
+ ~condition_variable_any() = default;
+
+ condition_variable_any(const condition_variable_any&) = delete;
+ condition_variable_any& operator=(const condition_variable_any&) = delete;
+
+ void
+ notify_one() noexcept
+ {
+ lock_guard<mutex> __lock(*_M_mutex);
+ _M_cond.notify_one();
+ }
+
+ void
+ notify_all() noexcept
+ {
+ lock_guard<mutex> __lock(*_M_mutex);
+ _M_cond.notify_all();
+ }
+
+ template<typename _Lock>
+ void
+ wait(_Lock& __lock)
+ {
+ shared_ptr<mutex> __mutex = _M_mutex;
+ unique_lock<mutex> __my_lock(*__mutex);
+ _Unlock<_Lock> __unlock(__lock);
+ // *__mutex must be unlocked before re-locking __lock so move
+ // ownership of *__mutex lock to an object with shorter lifetime.
+ unique_lock<mutex> __my_lock2(std::move(__my_lock));
+ _M_cond.wait(__my_lock2);
+ }
+
+
+ template<typename _Lock, typename _Predicate>
+ void
+ wait(_Lock& __lock, _Predicate __p)
+ {
+ while (!__p())
+ wait(__lock);
+ }
+
+ template<typename _Lock, typename _Clock, typename _Duration>
+ cv_status
+ wait_until(_Lock& __lock,
+ const chrono::time_point<_Clock, _Duration>& __atime)
+ {
+ shared_ptr<mutex> __mutex = _M_mutex;
+ unique_lock<mutex> __my_lock(*__mutex);
+ _Unlock<_Lock> __unlock(__lock);
+ // *__mutex must be unlocked before re-locking __lock so move
+ // ownership of *__mutex lock to an object with shorter lifetime.
+ unique_lock<mutex> __my_lock2(std::move(__my_lock));
+ return _M_cond.wait_until(__my_lock2, __atime);
+ }
+
+ template<typename _Lock, typename _Clock,
+ typename _Duration, typename _Predicate>
+ bool
+ wait_until(_Lock& __lock,
+ const chrono::time_point<_Clock, _Duration>& __atime,
+ _Predicate __p)
+ {
+ while (!__p())
+ if (wait_until(__lock, __atime) == cv_status::timeout)
+ return __p();
+ return true;
+ }
+
+ template<typename _Lock, typename _Rep, typename _Period>
+ cv_status
+ wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __rtime)
+ { return wait_until(__lock, __clock_t::now() + __rtime); }
+
+ template<typename _Lock, typename _Rep,
+ typename _Period, typename _Predicate>
+ bool
+ wait_for(_Lock& __lock,
+ const chrono::duration<_Rep, _Period>& __rtime, _Predicate __p)
+ { return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
+ };
+
+ } // end inline namespace
+
+ // @} group condition_variables
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
+
+#endif // C++11
+
+#endif // _GLIBCXX_CONDITION_VARIABLE
diff --git a/gcc-4.9/libstdc++-v3/include/std/deque b/gcc-4.9/libstdc++-v3/include/std/deque
new file mode 100644
index 0000000..816c873
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/deque
@@ -0,0 +1,76 @@
+// <deque> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/deque
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_DEQUE
+#define _GLIBCXX_DEQUE 1
+
+#pragma GCC system_header
+
+#include <bits/stl_algobase.h>
+#include <bits/allocator.h>
+#include <bits/stl_construct.h>
+#include <bits/stl_uninitialized.h>
+#include <bits/stl_deque.h>
+#include <bits/range_access.h>
+#include <bits/deque.tcc>
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/deque>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/deque>
+#endif
+
+#endif /* _GLIBCXX_DEQUE */
diff --git a/gcc-4.9/libstdc++-v3/include/std/forward_list b/gcc-4.9/libstdc++-v3/include/std/forward_list
new file mode 100644
index 0000000..d0c1503
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/forward_list
@@ -0,0 +1,52 @@
+// <forward_list> -*- C++ -*-
+
+// Copyright (C) 2008-2014 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/forward_list
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_FORWARD_LIST
+#define _GLIBCXX_FORWARD_LIST 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <bits/forward_list.h>
+#include <bits/range_access.h>
+#include <bits/forward_list.tcc>
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/forward_list>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/forward_list>
+#endif
+
+#endif // C++11
+
+#endif // _GLIBCXX_FORWARD_LIST
diff --git a/gcc-4.9/libstdc++-v3/include/std/fstream b/gcc-4.9/libstdc++-v3/include/std/fstream
new file mode 100644
index 0000000..17ccac6
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/fstream
@@ -0,0 +1,941 @@
+// File based streams -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/fstream
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 27.8 File-based streams
+//
+
+#ifndef _GLIBCXX_FSTREAM
+#define _GLIBCXX_FSTREAM 1
+
+#pragma GCC system_header
+
+#include <istream>
+#include <ostream>
+#include <bits/codecvt.h>
+#include <cstdio> // For BUFSIZ
+#include <bits/basic_file.h> // For __basic_file, __c_lock
+#if __cplusplus >= 201103L
+#include <string> // For std::string overloads.
+#endif
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // [27.8.1.1] template class basic_filebuf
+ /**
+ * @brief The actual work of input and output (for files).
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ *
+ * This class associates both its input and output sequence with an
+ * external disk file, and maintains a joint file position for both
+ * sequences. Many of its semantics are described in terms of similar
+ * behavior in the Standard C Library's @c FILE streams.
+ *
+ * Requirements on traits_type, specific to this class:
+ * - traits_type::pos_type must be fpos<traits_type::state_type>
+ * - traits_type::off_type must be streamoff
+ * - traits_type::state_type must be Assignable and DefaultConstructible,
+ * - traits_type::state_type() must be the initial state for codecvt.
+ */
+ template<typename _CharT, typename _Traits>
+ class basic_filebuf : public basic_streambuf<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ typedef basic_streambuf<char_type, traits_type> __streambuf_type;
+ typedef basic_filebuf<char_type, traits_type> __filebuf_type;
+ typedef __basic_file<char> __file_type;
+ typedef typename traits_type::state_type __state_type;
+ typedef codecvt<char_type, char, __state_type> __codecvt_type;
+
+ friend class ios_base; // For sync_with_stdio.
+
+ protected:
+ // Data Members:
+ // MT lock inherited from libio or other low-level io library.
+ __c_lock _M_lock;
+
+ // External buffer.
+ __file_type _M_file;
+
+ /// Place to stash in || out || in | out settings for current filebuf.
+ ios_base::openmode _M_mode;
+
+ // Beginning state type for codecvt.
+ __state_type _M_state_beg;
+
+ // During output, the state that corresponds to pptr(),
+ // during input, the state that corresponds to egptr() and
+ // _M_ext_next.
+ __state_type _M_state_cur;
+
+ // Not used for output. During input, the state that corresponds
+ // to eback() and _M_ext_buf.
+ __state_type _M_state_last;
+
+ /// Pointer to the beginning of internal buffer.
+ char_type* _M_buf;
+
+ /**
+ * Actual size of internal buffer. This number is equal to the size
+ * of the put area + 1 position, reserved for the overflow char of
+ * a full area.
+ */
+ size_t _M_buf_size;
+
+ // Set iff _M_buf is allocated memory from _M_allocate_internal_buffer.
+ bool _M_buf_allocated;
+
+ /**
+ * _M_reading == false && _M_writing == false for @b uncommitted mode;
+ * _M_reading == true for @b read mode;
+ * _M_writing == true for @b write mode;
+ *
+ * NB: _M_reading == true && _M_writing == true is unused.
+ */
+ bool _M_reading;
+ bool _M_writing;
+
+ //@{
+ /**
+ * Necessary bits for putback buffer management.
+ *
+ * @note pbacks of over one character are not currently supported.
+ */
+ char_type _M_pback;
+ char_type* _M_pback_cur_save;
+ char_type* _M_pback_end_save;
+ bool _M_pback_init;
+ //@}
+
+ // Cached codecvt facet.
+ const __codecvt_type* _M_codecvt;
+
+ /**
+ * Buffer for external characters. Used for input when
+ * codecvt::always_noconv() == false. When valid, this corresponds
+ * to eback().
+ */
+ char* _M_ext_buf;
+
+ /**
+ * Size of buffer held by _M_ext_buf.
+ */
+ streamsize _M_ext_buf_size;
+
+ /**
+ * Pointers into the buffer held by _M_ext_buf that delimit a
+ * subsequence of bytes that have been read but not yet converted.
+ * When valid, _M_ext_next corresponds to egptr().
+ */
+ const char* _M_ext_next;
+ char* _M_ext_end;
+
+ /**
+ * Initializes pback buffers, and moves normal buffers to safety.
+ * Assumptions:
+ * _M_in_cur has already been moved back
+ */
+ void
+ _M_create_pback()
+ {
+ if (!_M_pback_init)
+ {
+ _M_pback_cur_save = this->gptr();
+ _M_pback_end_save = this->egptr();
+ this->setg(&_M_pback, &_M_pback, &_M_pback + 1);
+ _M_pback_init = true;
+ }
+ }
+
+ /**
+ * Deactivates pback buffer contents, and restores normal buffer.
+ * Assumptions:
+ * The pback buffer has only moved forward.
+ */
+ void
+ _M_destroy_pback() throw()
+ {
+ if (_M_pback_init)
+ {
+ // Length _M_in_cur moved in the pback buffer.
+ _M_pback_cur_save += this->gptr() != this->eback();
+ this->setg(_M_buf, _M_pback_cur_save, _M_pback_end_save);
+ _M_pback_init = false;
+ }
+ }
+
+ public:
+ // Constructors/destructor:
+ /**
+ * @brief Does not open any files.
+ *
+ * The default constructor initializes the parent class using its
+ * own default ctor.
+ */
+ basic_filebuf();
+
+ /**
+ * @brief The destructor closes the file first.
+ */
+ virtual
+ ~basic_filebuf()
+ { this->close(); }
+
+ // Members:
+ /**
+ * @brief Returns true if the external file is open.
+ */
+ bool
+ is_open() const throw()
+ { return _M_file.is_open(); }
+
+ /**
+ * @brief Opens an external file.
+ * @param __s The name of the file.
+ * @param __mode The open mode flags.
+ * @return @c this on success, NULL on failure
+ *
+ * If a file is already open, this function immediately fails.
+ * Otherwise it tries to open the file named @a __s using the flags
+ * given in @a __mode.
+ *
+ * Table 92, adapted here, gives the relation between openmode
+ * combinations and the equivalent @c fopen() flags.
+ * (NB: lines app, in|out|app, in|app, binary|app, binary|in|out|app,
+ * and binary|in|app per DR 596)
+ * <pre>
+ * +---------------------------------------------------------+
+ * | ios_base Flag combination stdio equivalent |
+ * |binary in out trunc app |
+ * +---------------------------------------------------------+
+ * | + w |
+ * | + + a |
+ * | + a |
+ * | + + w |
+ * | + r |
+ * | + + r+ |
+ * | + + + w+ |
+ * | + + + a+ |
+ * | + + a+ |
+ * +---------------------------------------------------------+
+ * | + + wb |
+ * | + + + ab |
+ * | + + ab |
+ * | + + + wb |
+ * | + + rb |
+ * | + + + r+b |
+ * | + + + + w+b |
+ * | + + + + a+b |
+ * | + + + a+b |
+ * +---------------------------------------------------------+
+ * </pre>
+ */
+ __filebuf_type*
+ open(const char* __s, ios_base::openmode __mode);
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Opens an external file.
+ * @param __s The name of the file.
+ * @param __mode The open mode flags.
+ * @return @c this on success, NULL on failure
+ */
+ __filebuf_type*
+ open(const std::string& __s, ios_base::openmode __mode)
+ { return open(__s.c_str(), __mode); }
+#endif
+
+ /**
+ * @brief Closes the currently associated file.
+ * @return @c this on success, NULL on failure
+ *
+ * If no file is currently open, this function immediately fails.
+ *
+ * If a <em>put buffer area</em> exists, @c overflow(eof) is
+ * called to flush all the characters. The file is then
+ * closed.
+ *
+ * If any operations fail, this function also fails.
+ */
+ __filebuf_type*
+ close();
+
+ protected:
+ void
+ _M_allocate_internal_buffer();
+
+ void
+ _M_destroy_internal_buffer() throw();
+
+ // [27.8.1.4] overridden virtual functions
+ virtual streamsize
+ showmanyc();
+
+ // Stroustrup, 1998, p. 628
+ // underflow() and uflow() functions are called to get the next
+ // character from the real input source when the buffer is empty.
+ // Buffered input uses underflow()
+
+ virtual int_type
+ underflow();
+
+ virtual int_type
+ pbackfail(int_type __c = _Traits::eof());
+
+ // Stroustrup, 1998, p 648
+ // The overflow() function is called to transfer characters to the
+ // real output destination when the buffer is full. A call to
+ // overflow(c) outputs the contents of the buffer plus the
+ // character c.
+ // 27.5.2.4.5
+ // Consume some sequence of the characters in the pending sequence.
+ virtual int_type
+ overflow(int_type __c = _Traits::eof());
+
+ // Convert internal byte sequence to external, char-based
+ // sequence via codecvt.
+ bool
+ _M_convert_to_external(char_type*, streamsize);
+
+ /**
+ * @brief Manipulates the buffer.
+ * @param __s Pointer to a buffer area.
+ * @param __n Size of @a __s.
+ * @return @c this
+ *
+ * If no file has been opened, and both @a __s and @a __n are zero, then
+ * the stream becomes unbuffered. Otherwise, @c __s is used as a
+ * buffer; see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html
+ * for more.
+ */
+ virtual __streambuf_type*
+ setbuf(char_type* __s, streamsize __n);
+
+ virtual pos_type
+ seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __mode = ios_base::in | ios_base::out);
+
+ virtual pos_type
+ seekpos(pos_type __pos,
+ ios_base::openmode __mode = ios_base::in | ios_base::out);
+
+ // Common code for seekoff, seekpos, and overflow
+ pos_type
+ _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state);
+
+ int
+ _M_get_ext_pos(__state_type &__state);
+
+ virtual int
+ sync();
+
+ virtual void
+ imbue(const locale& __loc);
+
+ virtual streamsize
+ xsgetn(char_type* __s, streamsize __n);
+
+ virtual streamsize
+ xsputn(const char_type* __s, streamsize __n);
+
+ // Flushes output buffer, then writes unshift sequence.
+ bool
+ _M_terminate_output();
+
+ /**
+ * This function sets the pointers of the internal buffer, both get
+ * and put areas. Typically:
+ *
+ * __off == egptr() - eback() upon underflow/uflow (@b read mode);
+ * __off == 0 upon overflow (@b write mode);
+ * __off == -1 upon open, setbuf, seekoff/pos (@b uncommitted mode).
+ *
+ * NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size
+ * reflects the actual allocated memory and the last cell is reserved
+ * for the overflow char of a full put area.
+ */
+ void
+ _M_set_buffer(streamsize __off)
+ {
+ const bool __testin = _M_mode & ios_base::in;
+ const bool __testout = (_M_mode & ios_base::out
+ || _M_mode & ios_base::app);
+
+ if (__testin && __off > 0)
+ this->setg(_M_buf, _M_buf, _M_buf + __off);
+ else
+ this->setg(_M_buf, _M_buf, _M_buf);
+
+ if (__testout && __off == 0 && _M_buf_size > 1 )
+ this->setp(_M_buf, _M_buf + _M_buf_size - 1);
+ else
+ this->setp(0, 0);
+ }
+ };
+
+ // [27.8.1.5] Template class basic_ifstream
+ /**
+ * @brief Controlling input for files.
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ *
+ * This class supports reading from named files, using the inherited
+ * functions from std::basic_istream. To control the associated
+ * sequence, an instance of std::basic_filebuf is used, which this page
+ * refers to as @c sb.
+ */
+ template<typename _CharT, typename _Traits>
+ class basic_ifstream : public basic_istream<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // Non-standard types:
+ typedef basic_filebuf<char_type, traits_type> __filebuf_type;
+ typedef basic_istream<char_type, traits_type> __istream_type;
+
+ private:
+ __filebuf_type _M_filebuf;
+
+ public:
+ // Constructors/Destructors:
+ /**
+ * @brief Default constructor.
+ *
+ * Initializes @c sb using its default constructor, and passes
+ * @c &sb to the base class initializer. Does not open any files
+ * (you haven't given it a filename to open).
+ */
+ basic_ifstream() : __istream_type(), _M_filebuf()
+ { this->init(&_M_filebuf); }
+
+ /**
+ * @brief Create an input file stream.
+ * @param __s Null terminated string specifying the filename.
+ * @param __mode Open file in specified mode (see std::ios_base).
+ *
+ * @c ios_base::in is automatically included in @a __mode.
+ *
+ * Tip: When using std::string to hold the filename, you must use
+ * .c_str() before passing it to this constructor.
+ */
+ explicit
+ basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in)
+ : __istream_type(), _M_filebuf()
+ {
+ this->init(&_M_filebuf);
+ this->open(__s, __mode);
+ }
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Create an input file stream.
+ * @param __s std::string specifying the filename.
+ * @param __mode Open file in specified mode (see std::ios_base).
+ *
+ * @c ios_base::in is automatically included in @a __mode.
+ */
+ explicit
+ basic_ifstream(const std::string& __s,
+ ios_base::openmode __mode = ios_base::in)
+ : __istream_type(), _M_filebuf()
+ {
+ this->init(&_M_filebuf);
+ this->open(__s, __mode);
+ }
+#endif
+
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The file is closed by the filebuf object, not the formatting
+ * stream.
+ */
+ ~basic_ifstream()
+ { }
+
+ // Members:
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_filebuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
+ */
+ __filebuf_type*
+ rdbuf() const
+ { return const_cast<__filebuf_type*>(&_M_filebuf); }
+
+ /**
+ * @brief Wrapper to test for an open file.
+ * @return @c rdbuf()->is_open()
+ */
+ bool
+ is_open()
+ { return _M_filebuf.is_open(); }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 365. Lack of const-qualification in clause 27
+ bool
+ is_open() const
+ { return _M_filebuf.is_open(); }
+
+ /**
+ * @brief Opens an external file.
+ * @param __s The name of the file.
+ * @param __mode The open mode flags.
+ *
+ * Calls @c std::basic_filebuf::open(s,__mode|in). If that function
+ * fails, @c failbit is set in the stream's error state.
+ *
+ * Tip: When using std::string to hold the filename, you must use
+ * .c_str() before passing it to this constructor.
+ */
+ void
+ open(const char* __s, ios_base::openmode __mode = ios_base::in)
+ {
+ if (!_M_filebuf.open(__s, __mode | ios_base::in))
+ this->setstate(ios_base::failbit);
+ else
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 409. Closing an fstream should clear error state
+ this->clear();
+ }
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Opens an external file.
+ * @param __s The name of the file.
+ * @param __mode The open mode flags.
+ *
+ * Calls @c std::basic_filebuf::open(__s,__mode|in). If that function
+ * fails, @c failbit is set in the stream's error state.
+ */
+ void
+ open(const std::string& __s, ios_base::openmode __mode = ios_base::in)
+ {
+ if (!_M_filebuf.open(__s, __mode | ios_base::in))
+ this->setstate(ios_base::failbit);
+ else
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 409. Closing an fstream should clear error state
+ this->clear();
+ }
+#endif
+
+ /**
+ * @brief Close the file.
+ *
+ * Calls @c std::basic_filebuf::close(). If that function
+ * fails, @c failbit is set in the stream's error state.
+ */
+ void
+ close()
+ {
+ if (!_M_filebuf.close())
+ this->setstate(ios_base::failbit);
+ }
+ };
+
+
+ // [27.8.1.8] Template class basic_ofstream
+ /**
+ * @brief Controlling output for files.
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ *
+ * This class supports reading from named files, using the inherited
+ * functions from std::basic_ostream. To control the associated
+ * sequence, an instance of std::basic_filebuf is used, which this page
+ * refers to as @c sb.
+ */
+ template<typename _CharT, typename _Traits>
+ class basic_ofstream : public basic_ostream<_CharT,_Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // Non-standard types:
+ typedef basic_filebuf<char_type, traits_type> __filebuf_type;
+ typedef basic_ostream<char_type, traits_type> __ostream_type;
+
+ private:
+ __filebuf_type _M_filebuf;
+
+ public:
+ // Constructors:
+ /**
+ * @brief Default constructor.
+ *
+ * Initializes @c sb using its default constructor, and passes
+ * @c &sb to the base class initializer. Does not open any files
+ * (you haven't given it a filename to open).
+ */
+ basic_ofstream(): __ostream_type(), _M_filebuf()
+ { this->init(&_M_filebuf); }
+
+ /**
+ * @brief Create an output file stream.
+ * @param __s Null terminated string specifying the filename.
+ * @param __mode Open file in specified mode (see std::ios_base).
+ *
+ * @c ios_base::out | @c ios_base::trunc is automatically included in
+ * @a __mode.
+ *
+ * Tip: When using std::string to hold the filename, you must use
+ * .c_str() before passing it to this constructor.
+ */
+ explicit
+ basic_ofstream(const char* __s,
+ ios_base::openmode __mode = ios_base::out|ios_base::trunc)
+ : __ostream_type(), _M_filebuf()
+ {
+ this->init(&_M_filebuf);
+ this->open(__s, __mode);
+ }
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Create an output file stream.
+ * @param __s std::string specifying the filename.
+ * @param __mode Open file in specified mode (see std::ios_base).
+ *
+ * @c ios_base::out | @c ios_base::trunc is automatically included in
+ * @a __mode.
+ */
+ explicit
+ basic_ofstream(const std::string& __s,
+ ios_base::openmode __mode = ios_base::out|ios_base::trunc)
+ : __ostream_type(), _M_filebuf()
+ {
+ this->init(&_M_filebuf);
+ this->open(__s, __mode);
+ }
+#endif
+
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The file is closed by the filebuf object, not the formatting
+ * stream.
+ */
+ ~basic_ofstream()
+ { }
+
+ // Members:
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_filebuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
+ */
+ __filebuf_type*
+ rdbuf() const
+ { return const_cast<__filebuf_type*>(&_M_filebuf); }
+
+ /**
+ * @brief Wrapper to test for an open file.
+ * @return @c rdbuf()->is_open()
+ */
+ bool
+ is_open()
+ { return _M_filebuf.is_open(); }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 365. Lack of const-qualification in clause 27
+ bool
+ is_open() const
+ { return _M_filebuf.is_open(); }
+
+ /**
+ * @brief Opens an external file.
+ * @param __s The name of the file.
+ * @param __mode The open mode flags.
+ *
+ * Calls @c std::basic_filebuf::open(__s,__mode|out|trunc). If that
+ * function fails, @c failbit is set in the stream's error state.
+ *
+ * Tip: When using std::string to hold the filename, you must use
+ * .c_str() before passing it to this constructor.
+ */
+ void
+ open(const char* __s,
+ ios_base::openmode __mode = ios_base::out | ios_base::trunc)
+ {
+ if (!_M_filebuf.open(__s, __mode | ios_base::out))
+ this->setstate(ios_base::failbit);
+ else
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 409. Closing an fstream should clear error state
+ this->clear();
+ }
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Opens an external file.
+ * @param __s The name of the file.
+ * @param __mode The open mode flags.
+ *
+ * Calls @c std::basic_filebuf::open(s,mode|out|trunc). If that
+ * function fails, @c failbit is set in the stream's error state.
+ */
+ void
+ open(const std::string& __s,
+ ios_base::openmode __mode = ios_base::out | ios_base::trunc)
+ {
+ if (!_M_filebuf.open(__s, __mode | ios_base::out))
+ this->setstate(ios_base::failbit);
+ else
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 409. Closing an fstream should clear error state
+ this->clear();
+ }
+#endif
+
+ /**
+ * @brief Close the file.
+ *
+ * Calls @c std::basic_filebuf::close(). If that function
+ * fails, @c failbit is set in the stream's error state.
+ */
+ void
+ close()
+ {
+ if (!_M_filebuf.close())
+ this->setstate(ios_base::failbit);
+ }
+ };
+
+
+ // [27.8.1.11] Template class basic_fstream
+ /**
+ * @brief Controlling input and output for files.
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ *
+ * This class supports reading from and writing to named files, using
+ * the inherited functions from std::basic_iostream. To control the
+ * associated sequence, an instance of std::basic_filebuf is used, which
+ * this page refers to as @c sb.
+ */
+ template<typename _CharT, typename _Traits>
+ class basic_fstream : public basic_iostream<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // Non-standard types:
+ typedef basic_filebuf<char_type, traits_type> __filebuf_type;
+ typedef basic_ios<char_type, traits_type> __ios_type;
+ typedef basic_iostream<char_type, traits_type> __iostream_type;
+
+ private:
+ __filebuf_type _M_filebuf;
+
+ public:
+ // Constructors/destructor:
+ /**
+ * @brief Default constructor.
+ *
+ * Initializes @c sb using its default constructor, and passes
+ * @c &sb to the base class initializer. Does not open any files
+ * (you haven't given it a filename to open).
+ */
+ basic_fstream()
+ : __iostream_type(), _M_filebuf()
+ { this->init(&_M_filebuf); }
+
+ /**
+ * @brief Create an input/output file stream.
+ * @param __s Null terminated string specifying the filename.
+ * @param __mode Open file in specified mode (see std::ios_base).
+ *
+ * Tip: When using std::string to hold the filename, you must use
+ * .c_str() before passing it to this constructor.
+ */
+ explicit
+ basic_fstream(const char* __s,
+ ios_base::openmode __mode = ios_base::in | ios_base::out)
+ : __iostream_type(0), _M_filebuf()
+ {
+ this->init(&_M_filebuf);
+ this->open(__s, __mode);
+ }
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Create an input/output file stream.
+ * @param __s Null terminated string specifying the filename.
+ * @param __mode Open file in specified mode (see std::ios_base).
+ */
+ explicit
+ basic_fstream(const std::string& __s,
+ ios_base::openmode __mode = ios_base::in | ios_base::out)
+ : __iostream_type(0), _M_filebuf()
+ {
+ this->init(&_M_filebuf);
+ this->open(__s, __mode);
+ }
+#endif
+
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The file is closed by the filebuf object, not the formatting
+ * stream.
+ */
+ ~basic_fstream()
+ { }
+
+ // Members:
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_filebuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
+ */
+ __filebuf_type*
+ rdbuf() const
+ { return const_cast<__filebuf_type*>(&_M_filebuf); }
+
+ /**
+ * @brief Wrapper to test for an open file.
+ * @return @c rdbuf()->is_open()
+ */
+ bool
+ is_open()
+ { return _M_filebuf.is_open(); }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 365. Lack of const-qualification in clause 27
+ bool
+ is_open() const
+ { return _M_filebuf.is_open(); }
+
+ /**
+ * @brief Opens an external file.
+ * @param __s The name of the file.
+ * @param __mode The open mode flags.
+ *
+ * Calls @c std::basic_filebuf::open(__s,__mode). If that
+ * function fails, @c failbit is set in the stream's error state.
+ *
+ * Tip: When using std::string to hold the filename, you must use
+ * .c_str() before passing it to this constructor.
+ */
+ void
+ open(const char* __s,
+ ios_base::openmode __mode = ios_base::in | ios_base::out)
+ {
+ if (!_M_filebuf.open(__s, __mode))
+ this->setstate(ios_base::failbit);
+ else
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 409. Closing an fstream should clear error state
+ this->clear();
+ }
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Opens an external file.
+ * @param __s The name of the file.
+ * @param __mode The open mode flags.
+ *
+ * Calls @c std::basic_filebuf::open(__s,__mode). If that
+ * function fails, @c failbit is set in the stream's error state.
+ */
+ void
+ open(const std::string& __s,
+ ios_base::openmode __mode = ios_base::in | ios_base::out)
+ {
+ if (!_M_filebuf.open(__s, __mode))
+ this->setstate(ios_base::failbit);
+ else
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 409. Closing an fstream should clear error state
+ this->clear();
+ }
+#endif
+
+ /**
+ * @brief Close the file.
+ *
+ * Calls @c std::basic_filebuf::close(). If that function
+ * fails, @c failbit is set in the stream's error state.
+ */
+ void
+ close()
+ {
+ if (!_M_filebuf.close())
+ this->setstate(ios_base::failbit);
+ }
+ };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#include <bits/fstream.tcc>
+
+#endif /* _GLIBCXX_FSTREAM */
diff --git a/gcc-4.9/libstdc++-v3/include/std/functional b/gcc-4.9/libstdc++-v3/include/std/functional
new file mode 100644
index 0000000..5a987d9
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/functional
@@ -0,0 +1,2542 @@
+// <functional> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ * Copyright (c) 1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ */
+
+/** @file include/functional
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_FUNCTIONAL
+#define _GLIBCXX_FUNCTIONAL 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <bits/stl_function.h>
+
+#if __cplusplus >= 201103L
+
+#include <typeinfo>
+#include <new>
+#include <tuple>
+#include <type_traits>
+#include <bits/functexcept.h>
+#include <bits/functional_hash.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _MemberPointer>
+ class _Mem_fn;
+ template<typename _Tp, typename _Class>
+ _Mem_fn<_Tp _Class::*>
+ mem_fn(_Tp _Class::*) noexcept;
+
+_GLIBCXX_HAS_NESTED_TYPE(result_type)
+
+ /// If we have found a result_type, extract it.
+ template<bool _Has_result_type, typename _Functor>
+ struct _Maybe_get_result_type
+ { };
+
+ template<typename _Functor>
+ struct _Maybe_get_result_type<true, _Functor>
+ { typedef typename _Functor::result_type result_type; };
+
+ /**
+ * Base class for any function object that has a weak result type, as
+ * defined in 3.3/3 of TR1.
+ */
+ template<typename _Functor>
+ struct _Weak_result_type_impl
+ : _Maybe_get_result_type<__has_result_type<_Functor>::value, _Functor>
+ { };
+
+ /// Retrieve the result type for a function type.
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(_ArgTypes...)>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(_ArgTypes......)>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(_ArgTypes...) const>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(_ArgTypes......) const>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(_ArgTypes...) volatile>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(_ArgTypes......) volatile>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(_ArgTypes...) const volatile>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(_ArgTypes......) const volatile>
+ { typedef _Res result_type; };
+
+ /// Retrieve the result type for a function reference.
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(&)(_ArgTypes...)>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(&)(_ArgTypes......)>
+ { typedef _Res result_type; };
+
+ /// Retrieve the result type for a function pointer.
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(*)(_ArgTypes...)>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res(*)(_ArgTypes......)>
+ { typedef _Res result_type; };
+
+ /// Retrieve result type for a member function pointer.
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes...)>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes......)>
+ { typedef _Res result_type; };
+
+ /// Retrieve result type for a const member function pointer.
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes...) const>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes......) const>
+ { typedef _Res result_type; };
+
+ /// Retrieve result type for a volatile member function pointer.
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes...) volatile>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes......) volatile>
+ { typedef _Res result_type; };
+
+ /// Retrieve result type for a const volatile member function pointer.
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes...)
+ const volatile>
+ { typedef _Res result_type; };
+
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes......)
+ const volatile>
+ { typedef _Res result_type; };
+
+ /**
+ * Strip top-level cv-qualifiers from the function object and let
+ * _Weak_result_type_impl perform the real work.
+ */
+ template<typename _Functor>
+ struct _Weak_result_type
+ : _Weak_result_type_impl<typename remove_cv<_Functor>::type>
+ { };
+
+ /**
+ * Invoke a function object, which may be either a member pointer or a
+ * function object. The first parameter will tell which.
+ */
+ template<typename _Functor, typename... _Args>
+ inline
+ typename enable_if<
+ (!is_member_pointer<_Functor>::value
+ && !is_function<_Functor>::value
+ && !is_function<typename remove_pointer<_Functor>::type>::value),
+ typename result_of<_Functor&(_Args&&...)>::type
+ >::type
+ __invoke(_Functor& __f, _Args&&... __args)
+ {
+ return __f(std::forward<_Args>(__args)...);
+ }
+
+ template<typename _Functor, typename... _Args>
+ inline
+ typename enable_if<
+ (is_member_pointer<_Functor>::value
+ && !is_function<_Functor>::value
+ && !is_function<typename remove_pointer<_Functor>::type>::value),
+ typename result_of<_Functor(_Args&&...)>::type
+ >::type
+ __invoke(_Functor& __f, _Args&&... __args)
+ {
+ return std::mem_fn(__f)(std::forward<_Args>(__args)...);
+ }
+
+ // To pick up function references (that will become function pointers)
+ template<typename _Functor, typename... _Args>
+ inline
+ typename enable_if<
+ (is_pointer<_Functor>::value
+ && is_function<typename remove_pointer<_Functor>::type>::value),
+ typename result_of<_Functor(_Args&&...)>::type
+ >::type
+ __invoke(_Functor __f, _Args&&... __args)
+ {
+ return __f(std::forward<_Args>(__args)...);
+ }
+
+ /**
+ * Knowing which of unary_function and binary_function _Tp derives
+ * from, derives from the same and ensures that reference_wrapper
+ * will have a weak result type. See cases below.
+ */
+ template<bool _Unary, bool _Binary, typename _Tp>
+ struct _Reference_wrapper_base_impl;
+
+ // None of the nested argument types.
+ template<typename _Tp>
+ struct _Reference_wrapper_base_impl<false, false, _Tp>
+ : _Weak_result_type<_Tp>
+ { };
+
+ // Nested argument_type only.
+ template<typename _Tp>
+ struct _Reference_wrapper_base_impl<true, false, _Tp>
+ : _Weak_result_type<_Tp>
+ {
+ typedef typename _Tp::argument_type argument_type;
+ };
+
+ // Nested first_argument_type and second_argument_type only.
+ template<typename _Tp>
+ struct _Reference_wrapper_base_impl<false, true, _Tp>
+ : _Weak_result_type<_Tp>
+ {
+ typedef typename _Tp::first_argument_type first_argument_type;
+ typedef typename _Tp::second_argument_type second_argument_type;
+ };
+
+ // All the nested argument types.
+ template<typename _Tp>
+ struct _Reference_wrapper_base_impl<true, true, _Tp>
+ : _Weak_result_type<_Tp>
+ {
+ typedef typename _Tp::argument_type argument_type;
+ typedef typename _Tp::first_argument_type first_argument_type;
+ typedef typename _Tp::second_argument_type second_argument_type;
+ };
+
+ _GLIBCXX_HAS_NESTED_TYPE(argument_type)
+ _GLIBCXX_HAS_NESTED_TYPE(first_argument_type)
+ _GLIBCXX_HAS_NESTED_TYPE(second_argument_type)
+
+ /**
+ * Derives from unary_function or binary_function when it
+ * can. Specializations handle all of the easy cases. The primary
+ * template determines what to do with a class type, which may
+ * derive from both unary_function and binary_function.
+ */
+ template<typename _Tp>
+ struct _Reference_wrapper_base
+ : _Reference_wrapper_base_impl<
+ __has_argument_type<_Tp>::value,
+ __has_first_argument_type<_Tp>::value
+ && __has_second_argument_type<_Tp>::value,
+ _Tp>
+ { };
+
+ // - a function type (unary)
+ template<typename _Res, typename _T1>
+ struct _Reference_wrapper_base<_Res(_T1)>
+ : unary_function<_T1, _Res>
+ { };
+
+ template<typename _Res, typename _T1>
+ struct _Reference_wrapper_base<_Res(_T1) const>
+ : unary_function<_T1, _Res>
+ { };
+
+ template<typename _Res, typename _T1>
+ struct _Reference_wrapper_base<_Res(_T1) volatile>
+ : unary_function<_T1, _Res>
+ { };
+
+ template<typename _Res, typename _T1>
+ struct _Reference_wrapper_base<_Res(_T1) const volatile>
+ : unary_function<_T1, _Res>
+ { };
+
+ // - a function type (binary)
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Reference_wrapper_base<_Res(_T1, _T2)>
+ : binary_function<_T1, _T2, _Res>
+ { };
+
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Reference_wrapper_base<_Res(_T1, _T2) const>
+ : binary_function<_T1, _T2, _Res>
+ { };
+
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Reference_wrapper_base<_Res(_T1, _T2) volatile>
+ : binary_function<_T1, _T2, _Res>
+ { };
+
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Reference_wrapper_base<_Res(_T1, _T2) const volatile>
+ : binary_function<_T1, _T2, _Res>
+ { };
+
+ // - a function pointer type (unary)
+ template<typename _Res, typename _T1>
+ struct _Reference_wrapper_base<_Res(*)(_T1)>
+ : unary_function<_T1, _Res>
+ { };
+
+ // - a function pointer type (binary)
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Reference_wrapper_base<_Res(*)(_T1, _T2)>
+ : binary_function<_T1, _T2, _Res>
+ { };
+
+ // - a pointer to member function type (unary, no qualifiers)
+ template<typename _Res, typename _T1>
+ struct _Reference_wrapper_base<_Res (_T1::*)()>
+ : unary_function<_T1*, _Res>
+ { };
+
+ // - a pointer to member function type (binary, no qualifiers)
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Reference_wrapper_base<_Res (_T1::*)(_T2)>
+ : binary_function<_T1*, _T2, _Res>
+ { };
+
+ // - a pointer to member function type (unary, const)
+ template<typename _Res, typename _T1>
+ struct _Reference_wrapper_base<_Res (_T1::*)() const>
+ : unary_function<const _T1*, _Res>
+ { };
+
+ // - a pointer to member function type (binary, const)
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Reference_wrapper_base<_Res (_T1::*)(_T2) const>
+ : binary_function<const _T1*, _T2, _Res>
+ { };
+
+ // - a pointer to member function type (unary, volatile)
+ template<typename _Res, typename _T1>
+ struct _Reference_wrapper_base<_Res (_T1::*)() volatile>
+ : unary_function<volatile _T1*, _Res>
+ { };
+
+ // - a pointer to member function type (binary, volatile)
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Reference_wrapper_base<_Res (_T1::*)(_T2) volatile>
+ : binary_function<volatile _T1*, _T2, _Res>
+ { };
+
+ // - a pointer to member function type (unary, const volatile)
+ template<typename _Res, typename _T1>
+ struct _Reference_wrapper_base<_Res (_T1::*)() const volatile>
+ : unary_function<const volatile _T1*, _Res>
+ { };
+
+ // - a pointer to member function type (binary, const volatile)
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Reference_wrapper_base<_Res (_T1::*)(_T2) const volatile>
+ : binary_function<const volatile _T1*, _T2, _Res>
+ { };
+
+ /**
+ * @brief Primary class template for reference_wrapper.
+ * @ingroup functors
+ * @{
+ */
+ template<typename _Tp>
+ class reference_wrapper
+ : public _Reference_wrapper_base<typename remove_cv<_Tp>::type>
+ {
+ _Tp* _M_data;
+
+ public:
+ typedef _Tp type;
+
+ reference_wrapper(_Tp& __indata) noexcept
+ : _M_data(std::__addressof(__indata))
+ { }
+
+ reference_wrapper(_Tp&&) = delete;
+
+ reference_wrapper(const reference_wrapper<_Tp>& __inref) noexcept
+ : _M_data(__inref._M_data)
+ { }
+
+ reference_wrapper&
+ operator=(const reference_wrapper<_Tp>& __inref) noexcept
+ {
+ _M_data = __inref._M_data;
+ return *this;
+ }
+
+ operator _Tp&() const noexcept
+ { return this->get(); }
+
+ _Tp&
+ get() const noexcept
+ { return *_M_data; }
+
+ template<typename... _Args>
+ typename result_of<_Tp&(_Args&&...)>::type
+ operator()(_Args&&... __args) const
+ {
+ return __invoke(get(), std::forward<_Args>(__args)...);
+ }
+ };
+
+
+ /// Denotes a reference should be taken to a variable.
+ template<typename _Tp>
+ inline reference_wrapper<_Tp>
+ ref(_Tp& __t) noexcept
+ { return reference_wrapper<_Tp>(__t); }
+
+ /// Denotes a const reference should be taken to a variable.
+ template<typename _Tp>
+ inline reference_wrapper<const _Tp>
+ cref(const _Tp& __t) noexcept
+ { return reference_wrapper<const _Tp>(__t); }
+
+ template<typename _Tp>
+ void ref(const _Tp&&) = delete;
+
+ template<typename _Tp>
+ void cref(const _Tp&&) = delete;
+
+ /// Partial specialization.
+ template<typename _Tp>
+ inline reference_wrapper<_Tp>
+ ref(reference_wrapper<_Tp> __t) noexcept
+ { return ref(__t.get()); }
+
+ /// Partial specialization.
+ template<typename _Tp>
+ inline reference_wrapper<const _Tp>
+ cref(reference_wrapper<_Tp> __t) noexcept
+ { return cref(__t.get()); }
+
+ // @} group functors
+
+ template<typename... _Types>
+ struct _Pack : integral_constant<size_t, sizeof...(_Types)>
+ { };
+
+ template<typename _From, typename _To, bool = _From::value == _To::value>
+ struct _AllConvertible : false_type
+ { };
+
+ template<typename... _From, typename... _To>
+ struct _AllConvertible<_Pack<_From...>, _Pack<_To...>, true>
+ : __and_<is_convertible<_From, _To>...>
+ { };
+
+ template<typename _Tp1, typename _Tp2>
+ using _NotSame = __not_<is_same<typename std::decay<_Tp1>::type,
+ typename std::decay<_Tp2>::type>>;
+
+ /**
+ * Derives from @c unary_function or @c binary_function, or perhaps
+ * nothing, depending on the number of arguments provided. The
+ * primary template is the basis case, which derives nothing.
+ */
+ template<typename _Res, typename... _ArgTypes>
+ struct _Maybe_unary_or_binary_function { };
+
+ /// Derives from @c unary_function, as appropriate.
+ template<typename _Res, typename _T1>
+ struct _Maybe_unary_or_binary_function<_Res, _T1>
+ : std::unary_function<_T1, _Res> { };
+
+ /// Derives from @c binary_function, as appropriate.
+ template<typename _Res, typename _T1, typename _T2>
+ struct _Maybe_unary_or_binary_function<_Res, _T1, _T2>
+ : std::binary_function<_T1, _T2, _Res> { };
+
+ /// Implementation of @c mem_fn for member function pointers.
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ class _Mem_fn<_Res (_Class::*)(_ArgTypes...)>
+ : public _Maybe_unary_or_binary_function<_Res, _Class*, _ArgTypes...>
+ {
+ typedef _Res (_Class::*_Functor)(_ArgTypes...);
+
+ template<typename _Tp, typename... _Args>
+ _Res
+ _M_call(_Tp&& __object, const volatile _Class *,
+ _Args&&... __args) const
+ {
+ return (std::forward<_Tp>(__object).*__pmf)
+ (std::forward<_Args>(__args)...);
+ }
+
+ template<typename _Tp, typename... _Args>
+ _Res
+ _M_call(_Tp&& __ptr, const volatile void *, _Args&&... __args) const
+ { return ((*__ptr).*__pmf)(std::forward<_Args>(__args)...); }
+
+ // Require each _Args to be convertible to corresponding _ArgTypes
+ template<typename... _Args>
+ using _RequireValidArgs
+ = _Require<_AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ // Require each _Args to be convertible to corresponding _ArgTypes
+ // and require _Tp is not _Class, _Class& or _Class*
+ template<typename _Tp, typename... _Args>
+ using _RequireValidArgs2
+ = _Require<_NotSame<_Class, _Tp>, _NotSame<_Class*, _Tp>,
+ _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ // Require each _Args to be convertible to corresponding _ArgTypes
+ // and require _Tp is _Class or derived from _Class
+ template<typename _Tp, typename... _Args>
+ using _RequireValidArgs3
+ = _Require<is_base_of<_Class, _Tp>,
+ _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ public:
+ typedef _Res result_type;
+
+ explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
+
+ // Handle objects
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(_Class& __object, _Args&&... __args) const
+ { return (__object.*__pmf)(std::forward<_Args>(__args)...); }
+
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(_Class&& __object, _Args&&... __args) const
+ {
+ return (std::move(__object).*__pmf)(std::forward<_Args>(__args)...);
+ }
+
+ // Handle pointers
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(_Class* __object, _Args&&... __args) const
+ { return (__object->*__pmf)(std::forward<_Args>(__args)...); }
+
+ // Handle smart pointers, references and pointers to derived
+ template<typename _Tp, typename... _Args,
+ typename _Req = _RequireValidArgs2<_Tp, _Args...>>
+ _Res
+ operator()(_Tp&& __object, _Args&&... __args) const
+ {
+ return _M_call(std::forward<_Tp>(__object), &__object,
+ std::forward<_Args>(__args)...);
+ }
+
+ template<typename _Tp, typename... _Args,
+ typename _Req = _RequireValidArgs3<_Tp, _Args...>>
+ _Res
+ operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
+ { return operator()(__ref.get(), std::forward<_Args>(__args)...); }
+
+ private:
+ _Functor __pmf;
+ };
+
+ /// Implementation of @c mem_fn for const member function pointers.
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ class _Mem_fn<_Res (_Class::*)(_ArgTypes...) const>
+ : public _Maybe_unary_or_binary_function<_Res, const _Class*,
+ _ArgTypes...>
+ {
+ typedef _Res (_Class::*_Functor)(_ArgTypes...) const;
+
+ template<typename _Tp, typename... _Args>
+ _Res
+ _M_call(_Tp&& __object, const volatile _Class *,
+ _Args&&... __args) const
+ {
+ return (std::forward<_Tp>(__object).*__pmf)
+ (std::forward<_Args>(__args)...);
+ }
+
+ template<typename _Tp, typename... _Args>
+ _Res
+ _M_call(_Tp&& __ptr, const volatile void *, _Args&&... __args) const
+ { return ((*__ptr).*__pmf)(std::forward<_Args>(__args)...); }
+
+ template<typename... _Args>
+ using _RequireValidArgs
+ = _Require<_AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ template<typename _Tp, typename... _Args>
+ using _RequireValidArgs2
+ = _Require<_NotSame<_Class, _Tp>, _NotSame<const _Class*, _Tp>,
+ _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ template<typename _Tp, typename... _Args>
+ using _RequireValidArgs3
+ = _Require<is_base_of<_Class, _Tp>,
+ _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ public:
+ typedef _Res result_type;
+
+ explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
+
+ // Handle objects
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(const _Class& __object, _Args&&... __args) const
+ { return (__object.*__pmf)(std::forward<_Args>(__args)...); }
+
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(const _Class&& __object, _Args&&... __args) const
+ {
+ return (std::move(__object).*__pmf)(std::forward<_Args>(__args)...);
+ }
+
+ // Handle pointers
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(const _Class* __object, _Args&&... __args) const
+ { return (__object->*__pmf)(std::forward<_Args>(__args)...); }
+
+ // Handle smart pointers, references and pointers to derived
+ template<typename _Tp, typename... _Args,
+ typename _Req = _RequireValidArgs2<_Tp, _Args...>>
+ _Res operator()(_Tp&& __object, _Args&&... __args) const
+ {
+ return _M_call(std::forward<_Tp>(__object), &__object,
+ std::forward<_Args>(__args)...);
+ }
+
+ template<typename _Tp, typename... _Args,
+ typename _Req = _RequireValidArgs3<_Tp, _Args...>>
+ _Res
+ operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
+ { return operator()(__ref.get(), std::forward<_Args>(__args)...); }
+
+ private:
+ _Functor __pmf;
+ };
+
+ /// Implementation of @c mem_fn for volatile member function pointers.
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ class _Mem_fn<_Res (_Class::*)(_ArgTypes...) volatile>
+ : public _Maybe_unary_or_binary_function<_Res, volatile _Class*,
+ _ArgTypes...>
+ {
+ typedef _Res (_Class::*_Functor)(_ArgTypes...) volatile;
+
+ template<typename _Tp, typename... _Args>
+ _Res
+ _M_call(_Tp&& __object, const volatile _Class *,
+ _Args&&... __args) const
+ {
+ return (std::forward<_Tp>(__object).*__pmf)
+ (std::forward<_Args>(__args)...);
+ }
+
+ template<typename _Tp, typename... _Args>
+ _Res
+ _M_call(_Tp&& __ptr, const volatile void *, _Args&&... __args) const
+ { return ((*__ptr).*__pmf)(std::forward<_Args>(__args)...); }
+
+ template<typename... _Args>
+ using _RequireValidArgs
+ = _Require<_AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ template<typename _Tp, typename... _Args>
+ using _RequireValidArgs2
+ = _Require<_NotSame<_Class, _Tp>, _NotSame<volatile _Class*, _Tp>,
+ _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ template<typename _Tp, typename... _Args>
+ using _RequireValidArgs3
+ = _Require<is_base_of<_Class, _Tp>,
+ _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ public:
+ typedef _Res result_type;
+
+ explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
+
+ // Handle objects
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(volatile _Class& __object, _Args&&... __args) const
+ { return (__object.*__pmf)(std::forward<_Args>(__args)...); }
+
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(volatile _Class&& __object, _Args&&... __args) const
+ {
+ return (std::move(__object).*__pmf)(std::forward<_Args>(__args)...);
+ }
+
+ // Handle pointers
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(volatile _Class* __object, _Args&&... __args) const
+ { return (__object->*__pmf)(std::forward<_Args>(__args)...); }
+
+ // Handle smart pointers, references and pointers to derived
+ template<typename _Tp, typename... _Args,
+ typename _Req = _RequireValidArgs2<_Tp, _Args...>>
+ _Res
+ operator()(_Tp&& __object, _Args&&... __args) const
+ {
+ return _M_call(std::forward<_Tp>(__object), &__object,
+ std::forward<_Args>(__args)...);
+ }
+
+ template<typename _Tp, typename... _Args,
+ typename _Req = _RequireValidArgs3<_Tp, _Args...>>
+ _Res
+ operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
+ { return operator()(__ref.get(), std::forward<_Args>(__args)...); }
+
+ private:
+ _Functor __pmf;
+ };
+
+ /// Implementation of @c mem_fn for const volatile member function pointers.
+ template<typename _Res, typename _Class, typename... _ArgTypes>
+ class _Mem_fn<_Res (_Class::*)(_ArgTypes...) const volatile>
+ : public _Maybe_unary_or_binary_function<_Res, const volatile _Class*,
+ _ArgTypes...>
+ {
+ typedef _Res (_Class::*_Functor)(_ArgTypes...) const volatile;
+
+ template<typename _Tp, typename... _Args>
+ _Res
+ _M_call(_Tp&& __object, const volatile _Class *,
+ _Args&&... __args) const
+ {
+ return (std::forward<_Tp>(__object).*__pmf)
+ (std::forward<_Args>(__args)...);
+ }
+
+ template<typename _Tp, typename... _Args>
+ _Res
+ _M_call(_Tp&& __ptr, const volatile void *, _Args&&... __args) const
+ { return ((*__ptr).*__pmf)(std::forward<_Args>(__args)...); }
+
+ template<typename... _Args>
+ using _RequireValidArgs
+ = _Require<_AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ template<typename _Tp, typename... _Args>
+ using _RequireValidArgs2
+ = _Require<_NotSame<_Class, _Tp>,
+ _NotSame<const volatile _Class*, _Tp>,
+ _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ template<typename _Tp, typename... _Args>
+ using _RequireValidArgs3
+ = _Require<is_base_of<_Class, _Tp>,
+ _AllConvertible<_Pack<_Args...>, _Pack<_ArgTypes...>>>;
+
+ public:
+ typedef _Res result_type;
+
+ explicit _Mem_fn(_Functor __pmf) : __pmf(__pmf) { }
+
+ // Handle objects
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(const volatile _Class& __object, _Args&&... __args) const
+ { return (__object.*__pmf)(std::forward<_Args>(__args)...); }
+
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(const volatile _Class&& __object, _Args&&... __args) const
+ {
+ return (std::move(__object).*__pmf)(std::forward<_Args>(__args)...);
+ }
+
+ // Handle pointers
+ template<typename... _Args, typename _Req = _RequireValidArgs<_Args...>>
+ _Res
+ operator()(const volatile _Class* __object, _Args&&... __args) const
+ { return (__object->*__pmf)(std::forward<_Args>(__args)...); }
+
+ // Handle smart pointers, references and pointers to derived
+ template<typename _Tp, typename... _Args,
+ typename _Req = _RequireValidArgs2<_Tp, _Args...>>
+ _Res operator()(_Tp&& __object, _Args&&... __args) const
+ {
+ return _M_call(std::forward<_Tp>(__object), &__object,
+ std::forward<_Args>(__args)...);
+ }
+
+ template<typename _Tp, typename... _Args,
+ typename _Req = _RequireValidArgs3<_Tp, _Args...>>
+ _Res
+ operator()(reference_wrapper<_Tp> __ref, _Args&&... __args) const
+ { return operator()(__ref.get(), std::forward<_Args>(__args)...); }
+
+ private:
+ _Functor __pmf;
+ };
+
+
+ template<typename _Tp, bool>
+ struct _Mem_fn_const_or_non
+ {
+ typedef const _Tp& type;
+ };
+
+ template<typename _Tp>
+ struct _Mem_fn_const_or_non<_Tp, false>
+ {
+ typedef _Tp& type;
+ };
+
+ template<typename _Res, typename _Class>
+ class _Mem_fn<_Res _Class::*>
+ {
+ using __pm_type = _Res _Class::*;
+
+ // This bit of genius is due to Peter Dimov, improved slightly by
+ // Douglas Gregor.
+ // Made less elegant to support perfect forwarding and noexcept.
+ template<typename _Tp>
+ auto
+ _M_call(_Tp&& __object, const _Class *) const noexcept
+ -> decltype(std::forward<_Tp>(__object).*std::declval<__pm_type&>())
+ { return std::forward<_Tp>(__object).*__pm; }
+
+ template<typename _Tp, typename _Up>
+ auto
+ _M_call(_Tp&& __object, _Up * const *) const noexcept
+ -> decltype((*std::forward<_Tp>(__object)).*std::declval<__pm_type&>())
+ { return (*std::forward<_Tp>(__object)).*__pm; }
+
+ template<typename _Tp>
+ auto
+ _M_call(_Tp&& __ptr, const volatile void*) const
+ noexcept(noexcept((*__ptr).*std::declval<__pm_type&>()))
+ -> decltype((*__ptr).*std::declval<__pm_type&>())
+ { return (*__ptr).*__pm; }
+
+ public:
+ explicit
+ _Mem_fn(_Res _Class::*__pm) noexcept : __pm(__pm) { }
+
+ // Handle objects
+ _Res&
+ operator()(_Class& __object) const noexcept
+ { return __object.*__pm; }
+
+ const _Res&
+ operator()(const _Class& __object) const noexcept
+ { return __object.*__pm; }
+
+ _Res&&
+ operator()(_Class&& __object) const noexcept
+ { return std::forward<_Class>(__object).*__pm; }
+
+ const _Res&&
+ operator()(const _Class&& __object) const noexcept
+ { return std::forward<const _Class>(__object).*__pm; }
+
+ // Handle pointers
+ _Res&
+ operator()(_Class* __object) const noexcept
+ { return __object->*__pm; }
+
+ const _Res&
+ operator()(const _Class* __object) const noexcept
+ { return __object->*__pm; }
+
+ // Handle smart pointers and derived
+ template<typename _Tp, typename _Req = _Require<_NotSame<_Class*, _Tp>>>
+ auto
+ operator()(_Tp&& __unknown) const
+ noexcept(noexcept(std::declval<_Mem_fn*>()->_M_call
+ (std::forward<_Tp>(__unknown), &__unknown)))
+ -> decltype(this->_M_call(std::forward<_Tp>(__unknown), &__unknown))
+ { return _M_call(std::forward<_Tp>(__unknown), &__unknown); }
+
+ template<typename _Tp, typename _Req = _Require<is_base_of<_Class, _Tp>>>
+ auto
+ operator()(reference_wrapper<_Tp> __ref) const
+ noexcept(noexcept(std::declval<_Mem_fn&>()(__ref.get())))
+ -> decltype((*this)(__ref.get()))
+ { return (*this)(__ref.get()); }
+
+ private:
+ _Res _Class::*__pm;
+ };
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2048. Unnecessary mem_fn overloads
+ /**
+ * @brief Returns a function object that forwards to the member
+ * pointer @a pm.
+ * @ingroup functors
+ */
+ template<typename _Tp, typename _Class>
+ inline _Mem_fn<_Tp _Class::*>
+ mem_fn(_Tp _Class::* __pm) noexcept
+ {
+ return _Mem_fn<_Tp _Class::*>(__pm);
+ }
+
+ /**
+ * @brief Determines if the given type _Tp is a function object
+ * should be treated as a subexpression when evaluating calls to
+ * function objects returned by bind(). [TR1 3.6.1]
+ * @ingroup binders
+ */
+ template<typename _Tp>
+ struct is_bind_expression
+ : public false_type { };
+
+ /**
+ * @brief Determines if the given type _Tp is a placeholder in a
+ * bind() expression and, if so, which placeholder it is. [TR1 3.6.2]
+ * @ingroup binders
+ */
+ template<typename _Tp>
+ struct is_placeholder
+ : public integral_constant<int, 0>
+ { };
+
+ /** @brief The type of placeholder objects defined by libstdc++.
+ * @ingroup binders
+ */
+ template<int _Num> struct _Placeholder { };
+
+ _GLIBCXX_END_NAMESPACE_VERSION
+
+ /** @namespace std::placeholders
+ * @brief ISO C++11 entities sub-namespace for functional.
+ * @ingroup binders
+ */
+ namespace placeholders
+ {
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+ /* Define a large number of placeholders. There is no way to
+ * simplify this with variadic templates, because we're introducing
+ * unique names for each.
+ */
+ extern const _Placeholder<1> _1;
+ extern const _Placeholder<2> _2;
+ extern const _Placeholder<3> _3;
+ extern const _Placeholder<4> _4;
+ extern const _Placeholder<5> _5;
+ extern const _Placeholder<6> _6;
+ extern const _Placeholder<7> _7;
+ extern const _Placeholder<8> _8;
+ extern const _Placeholder<9> _9;
+ extern const _Placeholder<10> _10;
+ extern const _Placeholder<11> _11;
+ extern const _Placeholder<12> _12;
+ extern const _Placeholder<13> _13;
+ extern const _Placeholder<14> _14;
+ extern const _Placeholder<15> _15;
+ extern const _Placeholder<16> _16;
+ extern const _Placeholder<17> _17;
+ extern const _Placeholder<18> _18;
+ extern const _Placeholder<19> _19;
+ extern const _Placeholder<20> _20;
+ extern const _Placeholder<21> _21;
+ extern const _Placeholder<22> _22;
+ extern const _Placeholder<23> _23;
+ extern const _Placeholder<24> _24;
+ extern const _Placeholder<25> _25;
+ extern const _Placeholder<26> _26;
+ extern const _Placeholder<27> _27;
+ extern const _Placeholder<28> _28;
+ extern const _Placeholder<29> _29;
+ _GLIBCXX_END_NAMESPACE_VERSION
+ }
+
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * Partial specialization of is_placeholder that provides the placeholder
+ * number for the placeholder objects defined by libstdc++.
+ * @ingroup binders
+ */
+ template<int _Num>
+ struct is_placeholder<_Placeholder<_Num> >
+ : public integral_constant<int, _Num>
+ { };
+
+ template<int _Num>
+ struct is_placeholder<const _Placeholder<_Num> >
+ : public integral_constant<int, _Num>
+ { };
+
+ /**
+ * Used by _Safe_tuple_element to indicate that there is no tuple
+ * element at this position.
+ */
+ struct _No_tuple_element;
+
+ /**
+ * Implementation helper for _Safe_tuple_element. This primary
+ * template handles the case where it is safe to use @c
+ * tuple_element.
+ */
+ template<std::size_t __i, typename _Tuple, bool _IsSafe>
+ struct _Safe_tuple_element_impl
+ : tuple_element<__i, _Tuple> { };
+
+ /**
+ * Implementation helper for _Safe_tuple_element. This partial
+ * specialization handles the case where it is not safe to use @c
+ * tuple_element. We just return @c _No_tuple_element.
+ */
+ template<std::size_t __i, typename _Tuple>
+ struct _Safe_tuple_element_impl<__i, _Tuple, false>
+ {
+ typedef _No_tuple_element type;
+ };
+
+ /**
+ * Like tuple_element, but returns @c _No_tuple_element when
+ * tuple_element would return an error.
+ */
+ template<std::size_t __i, typename _Tuple>
+ struct _Safe_tuple_element
+ : _Safe_tuple_element_impl<__i, _Tuple,
+ (__i < tuple_size<_Tuple>::value)>
+ { };
+
+ /**
+ * Maps an argument to bind() into an actual argument to the bound
+ * function object [TR1 3.6.3/5]. Only the first parameter should
+ * be specified: the rest are used to determine among the various
+ * implementations. Note that, although this class is a function
+ * object, it isn't entirely normal because it takes only two
+ * parameters regardless of the number of parameters passed to the
+ * bind expression. The first parameter is the bound argument and
+ * the second parameter is a tuple containing references to the
+ * rest of the arguments.
+ */
+ template<typename _Arg,
+ bool _IsBindExp = is_bind_expression<_Arg>::value,
+ bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>
+ class _Mu;
+
+ /**
+ * If the argument is reference_wrapper<_Tp>, returns the
+ * underlying reference. [TR1 3.6.3/5 bullet 1]
+ */
+ template<typename _Tp>
+ class _Mu<reference_wrapper<_Tp>, false, false>
+ {
+ public:
+ typedef _Tp& result_type;
+
+ /* Note: This won't actually work for const volatile
+ * reference_wrappers, because reference_wrapper::get() is const
+ * but not volatile-qualified. This might be a defect in the TR.
+ */
+ template<typename _CVRef, typename _Tuple>
+ result_type
+ operator()(_CVRef& __arg, _Tuple&) const volatile
+ { return __arg.get(); }
+ };
+
+ /**
+ * If the argument is a bind expression, we invoke the underlying
+ * function object with the same cv-qualifiers as we are given and
+ * pass along all of our arguments (unwrapped). [TR1 3.6.3/5 bullet 2]
+ */
+ template<typename _Arg>
+ class _Mu<_Arg, true, false>
+ {
+ public:
+ template<typename _CVArg, typename... _Args>
+ auto
+ operator()(_CVArg& __arg,
+ tuple<_Args...>& __tuple) const volatile
+ -> decltype(__arg(declval<_Args>()...))
+ {
+ // Construct an index tuple and forward to __call
+ typedef typename _Build_index_tuple<sizeof...(_Args)>::__type
+ _Indexes;
+ return this->__call(__arg, __tuple, _Indexes());
+ }
+
+ private:
+ // Invokes the underlying function object __arg by unpacking all
+ // of the arguments in the tuple.
+ template<typename _CVArg, typename... _Args, std::size_t... _Indexes>
+ auto
+ __call(_CVArg& __arg, tuple<_Args...>& __tuple,
+ const _Index_tuple<_Indexes...>&) const volatile
+ -> decltype(__arg(declval<_Args>()...))
+ {
+ return __arg(std::forward<_Args>(get<_Indexes>(__tuple))...);
+ }
+ };
+
+ /**
+ * If the argument is a placeholder for the Nth argument, returns
+ * a reference to the Nth argument to the bind function object.
+ * [TR1 3.6.3/5 bullet 3]
+ */
+ template<typename _Arg>
+ class _Mu<_Arg, false, true>
+ {
+ public:
+ template<typename _Signature> class result;
+
+ template<typename _CVMu, typename _CVArg, typename _Tuple>
+ class result<_CVMu(_CVArg, _Tuple)>
+ {
+ // Add a reference, if it hasn't already been done for us.
+ // This allows us to be a little bit sloppy in constructing
+ // the tuple that we pass to result_of<...>.
+ typedef typename _Safe_tuple_element<(is_placeholder<_Arg>::value
+ - 1), _Tuple>::type
+ __base_type;
+
+ public:
+ typedef typename add_rvalue_reference<__base_type>::type type;
+ };
+
+ template<typename _Tuple>
+ typename result<_Mu(_Arg, _Tuple)>::type
+ operator()(const volatile _Arg&, _Tuple& __tuple) const volatile
+ {
+ return std::forward<typename result<_Mu(_Arg, _Tuple)>::type>(
+ ::std::get<(is_placeholder<_Arg>::value - 1)>(__tuple));
+ }
+ };
+
+ /**
+ * If the argument is just a value, returns a reference to that
+ * value. The cv-qualifiers on the reference are the same as the
+ * cv-qualifiers on the _Mu object. [TR1 3.6.3/5 bullet 4]
+ */
+ template<typename _Arg>
+ class _Mu<_Arg, false, false>
+ {
+ public:
+ template<typename _Signature> struct result;
+
+ template<typename _CVMu, typename _CVArg, typename _Tuple>
+ struct result<_CVMu(_CVArg, _Tuple)>
+ {
+ typedef typename add_lvalue_reference<_CVArg>::type type;
+ };
+
+ // Pick up the cv-qualifiers of the argument
+ template<typename _CVArg, typename _Tuple>
+ _CVArg&&
+ operator()(_CVArg&& __arg, _Tuple&) const volatile
+ { return std::forward<_CVArg>(__arg); }
+ };
+
+ /**
+ * Maps member pointers into instances of _Mem_fn but leaves all
+ * other function objects untouched. Used by tr1::bind(). The
+ * primary template handles the non--member-pointer case.
+ */
+ template<typename _Tp>
+ struct _Maybe_wrap_member_pointer
+ {
+ typedef _Tp type;
+
+ static const _Tp&
+ __do_wrap(const _Tp& __x)
+ { return __x; }
+
+ static _Tp&&
+ __do_wrap(_Tp&& __x)
+ { return static_cast<_Tp&&>(__x); }
+ };
+
+ /**
+ * Maps member pointers into instances of _Mem_fn but leaves all
+ * other function objects untouched. Used by tr1::bind(). This
+ * partial specialization handles the member pointer case.
+ */
+ template<typename _Tp, typename _Class>
+ struct _Maybe_wrap_member_pointer<_Tp _Class::*>
+ {
+ typedef _Mem_fn<_Tp _Class::*> type;
+
+ static type
+ __do_wrap(_Tp _Class::* __pm)
+ { return type(__pm); }
+ };
+
+ // Specialization needed to prevent "forming reference to void" errors when
+ // bind<void>() is called, because argument deduction instantiates
+ // _Maybe_wrap_member_pointer<void> outside the immediate context where
+ // SFINAE applies.
+ template<>
+ struct _Maybe_wrap_member_pointer<void>
+ {
+ typedef void type;
+ };
+
+ // std::get<I> for volatile-qualified tuples
+ template<std::size_t _Ind, typename... _Tp>
+ inline auto
+ __volget(volatile tuple<_Tp...>& __tuple)
+ -> typename tuple_element<_Ind, tuple<_Tp...>>::type volatile&
+ { return std::get<_Ind>(const_cast<tuple<_Tp...>&>(__tuple)); }
+
+ // std::get<I> for const-volatile-qualified tuples
+ template<std::size_t _Ind, typename... _Tp>
+ inline auto
+ __volget(const volatile tuple<_Tp...>& __tuple)
+ -> typename tuple_element<_Ind, tuple<_Tp...>>::type const volatile&
+ { return std::get<_Ind>(const_cast<const tuple<_Tp...>&>(__tuple)); }
+
+ /// Type of the function object returned from bind().
+ template<typename _Signature>
+ struct _Bind;
+
+ template<typename _Functor, typename... _Bound_args>
+ class _Bind<_Functor(_Bound_args...)>
+ : public _Weak_result_type<_Functor>
+ {
+ typedef _Bind __self_type;
+ typedef typename _Build_index_tuple<sizeof...(_Bound_args)>::__type
+ _Bound_indexes;
+
+ _Functor _M_f;
+ tuple<_Bound_args...> _M_bound_args;
+
+ // Call unqualified
+ template<typename _Result, typename... _Args, std::size_t... _Indexes>
+ _Result
+ __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>)
+ {
+ return _M_f(_Mu<_Bound_args>()
+ (get<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call as const
+ template<typename _Result, typename... _Args, std::size_t... _Indexes>
+ _Result
+ __call_c(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>) const
+ {
+ return _M_f(_Mu<_Bound_args>()
+ (get<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call as volatile
+ template<typename _Result, typename... _Args, std::size_t... _Indexes>
+ _Result
+ __call_v(tuple<_Args...>&& __args,
+ _Index_tuple<_Indexes...>) volatile
+ {
+ return _M_f(_Mu<_Bound_args>()
+ (__volget<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call as const volatile
+ template<typename _Result, typename... _Args, std::size_t... _Indexes>
+ _Result
+ __call_c_v(tuple<_Args...>&& __args,
+ _Index_tuple<_Indexes...>) const volatile
+ {
+ return _M_f(_Mu<_Bound_args>()
+ (__volget<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ public:
+ template<typename... _Args>
+ explicit _Bind(const _Functor& __f, _Args&&... __args)
+ : _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...)
+ { }
+
+ template<typename... _Args>
+ explicit _Bind(_Functor&& __f, _Args&&... __args)
+ : _M_f(std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...)
+ { }
+
+ _Bind(const _Bind&) = default;
+
+ _Bind(_Bind&& __b)
+ : _M_f(std::move(__b._M_f)), _M_bound_args(std::move(__b._M_bound_args))
+ { }
+
+ // Call unqualified
+ template<typename... _Args, typename _Result
+ = decltype( std::declval<_Functor>()(
+ _Mu<_Bound_args>()( std::declval<_Bound_args&>(),
+ std::declval<tuple<_Args...>&>() )... ) )>
+ _Result
+ operator()(_Args&&... __args)
+ {
+ return this->__call<_Result>(
+ std::forward_as_tuple(std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+
+ // Call as const
+ template<typename... _Args, typename _Result
+ = decltype( std::declval<typename enable_if<(sizeof...(_Args) >= 0),
+ typename add_const<_Functor>::type>::type>()(
+ _Mu<_Bound_args>()( std::declval<const _Bound_args&>(),
+ std::declval<tuple<_Args...>&>() )... ) )>
+ _Result
+ operator()(_Args&&... __args) const
+ {
+ return this->__call_c<_Result>(
+ std::forward_as_tuple(std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+
+ // Call as volatile
+ template<typename... _Args, typename _Result
+ = decltype( std::declval<typename enable_if<(sizeof...(_Args) >= 0),
+ typename add_volatile<_Functor>::type>::type>()(
+ _Mu<_Bound_args>()( std::declval<volatile _Bound_args&>(),
+ std::declval<tuple<_Args...>&>() )... ) )>
+ _Result
+ operator()(_Args&&... __args) volatile
+ {
+ return this->__call_v<_Result>(
+ std::forward_as_tuple(std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+
+ // Call as const volatile
+ template<typename... _Args, typename _Result
+ = decltype( std::declval<typename enable_if<(sizeof...(_Args) >= 0),
+ typename add_cv<_Functor>::type>::type>()(
+ _Mu<_Bound_args>()( std::declval<const volatile _Bound_args&>(),
+ std::declval<tuple<_Args...>&>() )... ) )>
+ _Result
+ operator()(_Args&&... __args) const volatile
+ {
+ return this->__call_c_v<_Result>(
+ std::forward_as_tuple(std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+ };
+
+ /// Type of the function object returned from bind<R>().
+ template<typename _Result, typename _Signature>
+ struct _Bind_result;
+
+ template<typename _Result, typename _Functor, typename... _Bound_args>
+ class _Bind_result<_Result, _Functor(_Bound_args...)>
+ {
+ typedef _Bind_result __self_type;
+ typedef typename _Build_index_tuple<sizeof...(_Bound_args)>::__type
+ _Bound_indexes;
+
+ _Functor _M_f;
+ tuple<_Bound_args...> _M_bound_args;
+
+ // sfinae types
+ template<typename _Res>
+ struct __enable_if_void : enable_if<is_void<_Res>::value, int> { };
+ template<typename _Res>
+ struct __disable_if_void : enable_if<!is_void<_Res>::value, int> { };
+
+ // Call unqualified
+ template<typename _Res, typename... _Args, std::size_t... _Indexes>
+ _Result
+ __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
+ typename __disable_if_void<_Res>::type = 0)
+ {
+ return _M_f(_Mu<_Bound_args>()
+ (get<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call unqualified, return void
+ template<typename _Res, typename... _Args, std::size_t... _Indexes>
+ void
+ __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
+ typename __enable_if_void<_Res>::type = 0)
+ {
+ _M_f(_Mu<_Bound_args>()
+ (get<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call as const
+ template<typename _Res, typename... _Args, std::size_t... _Indexes>
+ _Result
+ __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
+ typename __disable_if_void<_Res>::type = 0) const
+ {
+ return _M_f(_Mu<_Bound_args>()
+ (get<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call as const, return void
+ template<typename _Res, typename... _Args, std::size_t... _Indexes>
+ void
+ __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
+ typename __enable_if_void<_Res>::type = 0) const
+ {
+ _M_f(_Mu<_Bound_args>()
+ (get<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call as volatile
+ template<typename _Res, typename... _Args, std::size_t... _Indexes>
+ _Result
+ __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
+ typename __disable_if_void<_Res>::type = 0) volatile
+ {
+ return _M_f(_Mu<_Bound_args>()
+ (__volget<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call as volatile, return void
+ template<typename _Res, typename... _Args, std::size_t... _Indexes>
+ void
+ __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
+ typename __enable_if_void<_Res>::type = 0) volatile
+ {
+ _M_f(_Mu<_Bound_args>()
+ (__volget<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call as const volatile
+ template<typename _Res, typename... _Args, std::size_t... _Indexes>
+ _Result
+ __call(tuple<_Args...>&& __args, _Index_tuple<_Indexes...>,
+ typename __disable_if_void<_Res>::type = 0) const volatile
+ {
+ return _M_f(_Mu<_Bound_args>()
+ (__volget<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ // Call as const volatile, return void
+ template<typename _Res, typename... _Args, std::size_t... _Indexes>
+ void
+ __call(tuple<_Args...>&& __args,
+ _Index_tuple<_Indexes...>,
+ typename __enable_if_void<_Res>::type = 0) const volatile
+ {
+ _M_f(_Mu<_Bound_args>()
+ (__volget<_Indexes>(_M_bound_args), __args)...);
+ }
+
+ public:
+ typedef _Result result_type;
+
+ template<typename... _Args>
+ explicit _Bind_result(const _Functor& __f, _Args&&... __args)
+ : _M_f(__f), _M_bound_args(std::forward<_Args>(__args)...)
+ { }
+
+ template<typename... _Args>
+ explicit _Bind_result(_Functor&& __f, _Args&&... __args)
+ : _M_f(std::move(__f)), _M_bound_args(std::forward<_Args>(__args)...)
+ { }
+
+ _Bind_result(const _Bind_result&) = default;
+
+ _Bind_result(_Bind_result&& __b)
+ : _M_f(std::move(__b._M_f)), _M_bound_args(std::move(__b._M_bound_args))
+ { }
+
+ // Call unqualified
+ template<typename... _Args>
+ result_type
+ operator()(_Args&&... __args)
+ {
+ return this->__call<_Result>(
+ std::forward_as_tuple(std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+
+ // Call as const
+ template<typename... _Args>
+ result_type
+ operator()(_Args&&... __args) const
+ {
+ return this->__call<_Result>(
+ std::forward_as_tuple(std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+
+ // Call as volatile
+ template<typename... _Args>
+ result_type
+ operator()(_Args&&... __args) volatile
+ {
+ return this->__call<_Result>(
+ std::forward_as_tuple(std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+
+ // Call as const volatile
+ template<typename... _Args>
+ result_type
+ operator()(_Args&&... __args) const volatile
+ {
+ return this->__call<_Result>(
+ std::forward_as_tuple(std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+ };
+
+ /**
+ * @brief Class template _Bind is always a bind expression.
+ * @ingroup binders
+ */
+ template<typename _Signature>
+ struct is_bind_expression<_Bind<_Signature> >
+ : public true_type { };
+
+ /**
+ * @brief Class template _Bind is always a bind expression.
+ * @ingroup binders
+ */
+ template<typename _Signature>
+ struct is_bind_expression<const _Bind<_Signature> >
+ : public true_type { };
+
+ /**
+ * @brief Class template _Bind is always a bind expression.
+ * @ingroup binders
+ */
+ template<typename _Signature>
+ struct is_bind_expression<volatile _Bind<_Signature> >
+ : public true_type { };
+
+ /**
+ * @brief Class template _Bind is always a bind expression.
+ * @ingroup binders
+ */
+ template<typename _Signature>
+ struct is_bind_expression<const volatile _Bind<_Signature>>
+ : public true_type { };
+
+ /**
+ * @brief Class template _Bind_result is always a bind expression.
+ * @ingroup binders
+ */
+ template<typename _Result, typename _Signature>
+ struct is_bind_expression<_Bind_result<_Result, _Signature>>
+ : public true_type { };
+
+ /**
+ * @brief Class template _Bind_result is always a bind expression.
+ * @ingroup binders
+ */
+ template<typename _Result, typename _Signature>
+ struct is_bind_expression<const _Bind_result<_Result, _Signature>>
+ : public true_type { };
+
+ /**
+ * @brief Class template _Bind_result is always a bind expression.
+ * @ingroup binders
+ */
+ template<typename _Result, typename _Signature>
+ struct is_bind_expression<volatile _Bind_result<_Result, _Signature>>
+ : public true_type { };
+
+ /**
+ * @brief Class template _Bind_result is always a bind expression.
+ * @ingroup binders
+ */
+ template<typename _Result, typename _Signature>
+ struct is_bind_expression<const volatile _Bind_result<_Result, _Signature>>
+ : public true_type { };
+
+ // Trait type used to remove std::bind() from overload set via SFINAE
+ // when first argument has integer type, so that std::bind() will
+ // not be a better match than ::bind() from the BSD Sockets API.
+ template<typename _Tp, typename _Tp2 = typename decay<_Tp>::type>
+ using __is_socketlike = __or_<is_integral<_Tp2>, is_enum<_Tp2>>;
+
+ template<bool _SocketLike, typename _Func, typename... _BoundArgs>
+ struct _Bind_helper
+ {
+ typedef _Maybe_wrap_member_pointer<typename decay<_Func>::type>
+ __maybe_type;
+ typedef typename __maybe_type::type __func_type;
+ typedef _Bind<__func_type(typename decay<_BoundArgs>::type...)> type;
+ };
+
+ // Partial specialization for is_socketlike == true, does not define
+ // nested type so std::bind() will not participate in overload resolution
+ // when the first argument might be a socket file descriptor.
+ template<typename _Func, typename... _BoundArgs>
+ struct _Bind_helper<true, _Func, _BoundArgs...>
+ { };
+
+ /**
+ * @brief Function template for std::bind.
+ * @ingroup binders
+ */
+ template<typename _Func, typename... _BoundArgs>
+ inline typename
+ _Bind_helper<__is_socketlike<_Func>::value, _Func, _BoundArgs...>::type
+ bind(_Func&& __f, _BoundArgs&&... __args)
+ {
+ typedef _Bind_helper<false, _Func, _BoundArgs...> __helper_type;
+ typedef typename __helper_type::__maybe_type __maybe_type;
+ typedef typename __helper_type::type __result_type;
+ return __result_type(__maybe_type::__do_wrap(std::forward<_Func>(__f)),
+ std::forward<_BoundArgs>(__args)...);
+ }
+
+ template<typename _Result, typename _Func, typename... _BoundArgs>
+ struct _Bindres_helper
+ {
+ typedef _Maybe_wrap_member_pointer<typename decay<_Func>::type>
+ __maybe_type;
+ typedef typename __maybe_type::type __functor_type;
+ typedef _Bind_result<_Result,
+ __functor_type(typename decay<_BoundArgs>::type...)>
+ type;
+ };
+
+ /**
+ * @brief Function template for std::bind<R>.
+ * @ingroup binders
+ */
+ template<typename _Result, typename _Func, typename... _BoundArgs>
+ inline
+ typename _Bindres_helper<_Result, _Func, _BoundArgs...>::type
+ bind(_Func&& __f, _BoundArgs&&... __args)
+ {
+ typedef _Bindres_helper<_Result, _Func, _BoundArgs...> __helper_type;
+ typedef typename __helper_type::__maybe_type __maybe_type;
+ typedef typename __helper_type::type __result_type;
+ return __result_type(__maybe_type::__do_wrap(std::forward<_Func>(__f)),
+ std::forward<_BoundArgs>(__args)...);
+ }
+
+ template<typename _Signature>
+ struct _Bind_simple;
+
+ template<typename _Callable, typename... _Args>
+ struct _Bind_simple<_Callable(_Args...)>
+ {
+ typedef typename result_of<_Callable(_Args...)>::type result_type;
+
+ template<typename... _Args2, typename = typename
+ enable_if< sizeof...(_Args) == sizeof...(_Args2)>::type>
+ explicit
+ _Bind_simple(const _Callable& __callable, _Args2&&... __args)
+ : _M_bound(__callable, std::forward<_Args2>(__args)...)
+ { }
+
+ template<typename... _Args2, typename = typename
+ enable_if< sizeof...(_Args) == sizeof...(_Args2)>::type>
+ explicit
+ _Bind_simple(_Callable&& __callable, _Args2&&... __args)
+ : _M_bound(std::move(__callable), std::forward<_Args2>(__args)...)
+ { }
+
+ _Bind_simple(const _Bind_simple&) = default;
+ _Bind_simple(_Bind_simple&&) = default;
+
+ result_type
+ operator()()
+ {
+ typedef typename _Build_index_tuple<sizeof...(_Args)>::__type _Indices;
+ return _M_invoke(_Indices());
+ }
+
+ private:
+
+ template<std::size_t... _Indices>
+ typename result_of<_Callable(_Args...)>::type
+ _M_invoke(_Index_tuple<_Indices...>)
+ {
+ // std::bind always forwards bound arguments as lvalues,
+ // but this type can call functions which only accept rvalues.
+ return std::forward<_Callable>(std::get<0>(_M_bound))(
+ std::forward<_Args>(std::get<_Indices+1>(_M_bound))...);
+ }
+
+ std::tuple<_Callable, _Args...> _M_bound;
+ };
+
+ template<typename _Func, typename... _BoundArgs>
+ struct _Bind_simple_helper
+ {
+ typedef _Maybe_wrap_member_pointer<typename decay<_Func>::type>
+ __maybe_type;
+ typedef typename __maybe_type::type __func_type;
+ typedef _Bind_simple<__func_type(typename decay<_BoundArgs>::type...)>
+ __type;
+ };
+
+ // Simplified version of std::bind for internal use, without support for
+ // unbound arguments, placeholders or nested bind expressions.
+ template<typename _Callable, typename... _Args>
+ typename _Bind_simple_helper<_Callable, _Args...>::__type
+ __bind_simple(_Callable&& __callable, _Args&&... __args)
+ {
+ typedef _Bind_simple_helper<_Callable, _Args...> __helper_type;
+ typedef typename __helper_type::__maybe_type __maybe_type;
+ typedef typename __helper_type::__type __result_type;
+ return __result_type(
+ __maybe_type::__do_wrap( std::forward<_Callable>(__callable)),
+ std::forward<_Args>(__args)...);
+ }
+
+ /**
+ * @brief Exception class thrown when class template function's
+ * operator() is called with an empty target.
+ * @ingroup exceptions
+ */
+ class bad_function_call : public std::exception
+ {
+ public:
+ virtual ~bad_function_call() noexcept;
+
+ const char* what() const noexcept;
+ };
+
+ /**
+ * Trait identifying "location-invariant" types, meaning that the
+ * address of the object (or any of its members) will not escape.
+ * Also implies a trivial copy constructor and assignment operator.
+ */
+ template<typename _Tp>
+ struct __is_location_invariant
+ : integral_constant<bool, (is_pointer<_Tp>::value
+ || is_member_pointer<_Tp>::value)>
+ { };
+
+ class _Undefined_class;
+
+ union _Nocopy_types
+ {
+ void* _M_object;
+ const void* _M_const_object;
+ void (*_M_function_pointer)();
+ void (_Undefined_class::*_M_member_pointer)();
+ };
+
+ union _Any_data
+ {
+ void* _M_access() { return &_M_pod_data[0]; }
+ const void* _M_access() const { return &_M_pod_data[0]; }
+
+ template<typename _Tp>
+ _Tp&
+ _M_access()
+ { return *static_cast<_Tp*>(_M_access()); }
+
+ template<typename _Tp>
+ const _Tp&
+ _M_access() const
+ { return *static_cast<const _Tp*>(_M_access()); }
+
+ _Nocopy_types _M_unused;
+ char _M_pod_data[sizeof(_Nocopy_types)];
+ };
+
+ enum _Manager_operation
+ {
+ __get_type_info,
+ __get_functor_ptr,
+ __clone_functor,
+ __destroy_functor
+ };
+
+ // Simple type wrapper that helps avoid annoying const problems
+ // when casting between void pointers and pointers-to-pointers.
+ template<typename _Tp>
+ struct _Simple_type_wrapper
+ {
+ _Simple_type_wrapper(_Tp __value) : __value(__value) { }
+
+ _Tp __value;
+ };
+
+ template<typename _Tp>
+ struct __is_location_invariant<_Simple_type_wrapper<_Tp> >
+ : __is_location_invariant<_Tp>
+ { };
+
+ // Converts a reference to a function object into a callable
+ // function object.
+ template<typename _Functor>
+ inline _Functor&
+ __callable_functor(_Functor& __f)
+ { return __f; }
+
+ template<typename _Member, typename _Class>
+ inline _Mem_fn<_Member _Class::*>
+ __callable_functor(_Member _Class::* &__p)
+ { return std::mem_fn(__p); }
+
+ template<typename _Member, typename _Class>
+ inline _Mem_fn<_Member _Class::*>
+ __callable_functor(_Member _Class::* const &__p)
+ { return std::mem_fn(__p); }
+
+ template<typename _Member, typename _Class>
+ inline _Mem_fn<_Member _Class::*>
+ __callable_functor(_Member _Class::* volatile &__p)
+ { return std::mem_fn(__p); }
+
+ template<typename _Member, typename _Class>
+ inline _Mem_fn<_Member _Class::*>
+ __callable_functor(_Member _Class::* const volatile &__p)
+ { return std::mem_fn(__p); }
+
+ template<typename _Signature>
+ class function;
+
+ /// Base class of all polymorphic function object wrappers.
+ class _Function_base
+ {
+ public:
+ static const std::size_t _M_max_size = sizeof(_Nocopy_types);
+ static const std::size_t _M_max_align = __alignof__(_Nocopy_types);
+
+ template<typename _Functor>
+ class _Base_manager
+ {
+ protected:
+ static const bool __stored_locally =
+ (__is_location_invariant<_Functor>::value
+ && sizeof(_Functor) <= _M_max_size
+ && __alignof__(_Functor) <= _M_max_align
+ && (_M_max_align % __alignof__(_Functor) == 0));
+
+ typedef integral_constant<bool, __stored_locally> _Local_storage;
+
+ // Retrieve a pointer to the function object
+ static _Functor*
+ _M_get_pointer(const _Any_data& __source)
+ {
+ const _Functor* __ptr =
+ __stored_locally? std::__addressof(__source._M_access<_Functor>())
+ /* have stored a pointer */ : __source._M_access<_Functor*>();
+ return const_cast<_Functor*>(__ptr);
+ }
+
+ // Clone a location-invariant function object that fits within
+ // an _Any_data structure.
+ static void
+ _M_clone(_Any_data& __dest, const _Any_data& __source, true_type)
+ {
+ new (__dest._M_access()) _Functor(__source._M_access<_Functor>());
+ }
+
+ // Clone a function object that is not location-invariant or
+ // that cannot fit into an _Any_data structure.
+ static void
+ _M_clone(_Any_data& __dest, const _Any_data& __source, false_type)
+ {
+ __dest._M_access<_Functor*>() =
+ new _Functor(*__source._M_access<_Functor*>());
+ }
+
+ // Destroying a location-invariant object may still require
+ // destruction.
+ static void
+ _M_destroy(_Any_data& __victim, true_type)
+ {
+ __victim._M_access<_Functor>().~_Functor();
+ }
+
+ // Destroying an object located on the heap.
+ static void
+ _M_destroy(_Any_data& __victim, false_type)
+ {
+ delete __victim._M_access<_Functor*>();
+ }
+
+ public:
+ static bool
+ _M_manager(_Any_data& __dest, const _Any_data& __source,
+ _Manager_operation __op)
+ {
+ switch (__op)
+ {
+#ifdef __GXX_RTTI
+ case __get_type_info:
+ __dest._M_access<const type_info*>() = &typeid(_Functor);
+ break;
+#endif
+ case __get_functor_ptr:
+ __dest._M_access<_Functor*>() = _M_get_pointer(__source);
+ break;
+
+ case __clone_functor:
+ _M_clone(__dest, __source, _Local_storage());
+ break;
+
+ case __destroy_functor:
+ _M_destroy(__dest, _Local_storage());
+ break;
+ }
+ return false;
+ }
+
+ static void
+ _M_init_functor(_Any_data& __functor, _Functor&& __f)
+ { _M_init_functor(__functor, std::move(__f), _Local_storage()); }
+
+ template<typename _Signature>
+ static bool
+ _M_not_empty_function(const function<_Signature>& __f)
+ { return static_cast<bool>(__f); }
+
+ template<typename _Tp>
+ static bool
+ _M_not_empty_function(_Tp* const& __fp)
+ { return __fp; }
+
+ template<typename _Class, typename _Tp>
+ static bool
+ _M_not_empty_function(_Tp _Class::* const& __mp)
+ { return __mp; }
+
+ template<typename _Tp>
+ static bool
+ _M_not_empty_function(const _Tp&)
+ { return true; }
+
+ private:
+ static void
+ _M_init_functor(_Any_data& __functor, _Functor&& __f, true_type)
+ { new (__functor._M_access()) _Functor(std::move(__f)); }
+
+ static void
+ _M_init_functor(_Any_data& __functor, _Functor&& __f, false_type)
+ { __functor._M_access<_Functor*>() = new _Functor(std::move(__f)); }
+ };
+
+ template<typename _Functor>
+ class _Ref_manager : public _Base_manager<_Functor*>
+ {
+ typedef _Function_base::_Base_manager<_Functor*> _Base;
+
+ public:
+ static bool
+ _M_manager(_Any_data& __dest, const _Any_data& __source,
+ _Manager_operation __op)
+ {
+ switch (__op)
+ {
+#ifdef __GXX_RTTI
+ case __get_type_info:
+ __dest._M_access<const type_info*>() = &typeid(_Functor);
+ break;
+#endif
+ case __get_functor_ptr:
+ __dest._M_access<_Functor*>() = *_Base::_M_get_pointer(__source);
+ return is_const<_Functor>::value;
+ break;
+
+ default:
+ _Base::_M_manager(__dest, __source, __op);
+ }
+ return false;
+ }
+
+ static void
+ _M_init_functor(_Any_data& __functor, reference_wrapper<_Functor> __f)
+ {
+ _Base::_M_init_functor(__functor, std::__addressof(__f.get()));
+ }
+ };
+
+ _Function_base() : _M_manager(0) { }
+
+ ~_Function_base()
+ {
+ if (_M_manager)
+ _M_manager(_M_functor, _M_functor, __destroy_functor);
+ }
+
+
+ bool _M_empty() const { return !_M_manager; }
+
+ typedef bool (*_Manager_type)(_Any_data&, const _Any_data&,
+ _Manager_operation);
+
+ _Any_data _M_functor;
+ _Manager_type _M_manager;
+ };
+
+ template<typename _Signature, typename _Functor>
+ class _Function_handler;
+
+ template<typename _Res, typename _Functor, typename... _ArgTypes>
+ class _Function_handler<_Res(_ArgTypes...), _Functor>
+ : public _Function_base::_Base_manager<_Functor>
+ {
+ typedef _Function_base::_Base_manager<_Functor> _Base;
+
+ public:
+ static _Res
+ _M_invoke(const _Any_data& __functor, _ArgTypes... __args)
+ {
+ return (*_Base::_M_get_pointer(__functor))(
+ std::forward<_ArgTypes>(__args)...);
+ }
+ };
+
+ template<typename _Functor, typename... _ArgTypes>
+ class _Function_handler<void(_ArgTypes...), _Functor>
+ : public _Function_base::_Base_manager<_Functor>
+ {
+ typedef _Function_base::_Base_manager<_Functor> _Base;
+
+ public:
+ static void
+ _M_invoke(const _Any_data& __functor, _ArgTypes... __args)
+ {
+ (*_Base::_M_get_pointer(__functor))(
+ std::forward<_ArgTypes>(__args)...);
+ }
+ };
+
+ template<typename _Res, typename _Functor, typename... _ArgTypes>
+ class _Function_handler<_Res(_ArgTypes...), reference_wrapper<_Functor> >
+ : public _Function_base::_Ref_manager<_Functor>
+ {
+ typedef _Function_base::_Ref_manager<_Functor> _Base;
+
+ public:
+ static _Res
+ _M_invoke(const _Any_data& __functor, _ArgTypes... __args)
+ {
+ return __callable_functor(**_Base::_M_get_pointer(__functor))(
+ std::forward<_ArgTypes>(__args)...);
+ }
+ };
+
+ template<typename _Functor, typename... _ArgTypes>
+ class _Function_handler<void(_ArgTypes...), reference_wrapper<_Functor> >
+ : public _Function_base::_Ref_manager<_Functor>
+ {
+ typedef _Function_base::_Ref_manager<_Functor> _Base;
+
+ public:
+ static void
+ _M_invoke(const _Any_data& __functor, _ArgTypes... __args)
+ {
+ __callable_functor(**_Base::_M_get_pointer(__functor))(
+ std::forward<_ArgTypes>(__args)...);
+ }
+ };
+
+ template<typename _Class, typename _Member, typename _Res,
+ typename... _ArgTypes>
+ class _Function_handler<_Res(_ArgTypes...), _Member _Class::*>
+ : public _Function_handler<void(_ArgTypes...), _Member _Class::*>
+ {
+ typedef _Function_handler<void(_ArgTypes...), _Member _Class::*>
+ _Base;
+
+ public:
+ static _Res
+ _M_invoke(const _Any_data& __functor, _ArgTypes... __args)
+ {
+ return std::mem_fn(_Base::_M_get_pointer(__functor)->__value)(
+ std::forward<_ArgTypes>(__args)...);
+ }
+ };
+
+ template<typename _Class, typename _Member, typename... _ArgTypes>
+ class _Function_handler<void(_ArgTypes...), _Member _Class::*>
+ : public _Function_base::_Base_manager<
+ _Simple_type_wrapper< _Member _Class::* > >
+ {
+ typedef _Member _Class::* _Functor;
+ typedef _Simple_type_wrapper<_Functor> _Wrapper;
+ typedef _Function_base::_Base_manager<_Wrapper> _Base;
+
+ public:
+ static bool
+ _M_manager(_Any_data& __dest, const _Any_data& __source,
+ _Manager_operation __op)
+ {
+ switch (__op)
+ {
+#ifdef __GXX_RTTI
+ case __get_type_info:
+ __dest._M_access<const type_info*>() = &typeid(_Functor);
+ break;
+#endif
+ case __get_functor_ptr:
+ __dest._M_access<_Functor*>() =
+ &_Base::_M_get_pointer(__source)->__value;
+ break;
+
+ default:
+ _Base::_M_manager(__dest, __source, __op);
+ }
+ return false;
+ }
+
+ static void
+ _M_invoke(const _Any_data& __functor, _ArgTypes... __args)
+ {
+ std::mem_fn(_Base::_M_get_pointer(__functor)->__value)(
+ std::forward<_ArgTypes>(__args)...);
+ }
+ };
+
+ template<typename _From, typename _To>
+ using __check_func_return_type
+ = __or_<is_void<_To>, is_convertible<_From, _To>>;
+
+ /**
+ * @brief Primary class template for std::function.
+ * @ingroup functors
+ *
+ * Polymorphic function wrapper.
+ */
+ template<typename _Res, typename... _ArgTypes>
+ class function<_Res(_ArgTypes...)>
+ : public _Maybe_unary_or_binary_function<_Res, _ArgTypes...>,
+ private _Function_base
+ {
+ typedef _Res _Signature_type(_ArgTypes...);
+
+ template<typename _Functor>
+ using _Invoke = decltype(__callable_functor(std::declval<_Functor&>())
+ (std::declval<_ArgTypes>()...) );
+
+ template<typename _Functor>
+ using _Callable = __check_func_return_type<_Invoke<_Functor>, _Res>;
+
+ template<typename _Cond, typename _Tp>
+ using _Requires = typename enable_if<_Cond::value, _Tp>::type;
+
+ public:
+ typedef _Res result_type;
+
+ // [3.7.2.1] construct/copy/destroy
+
+ /**
+ * @brief Default construct creates an empty function call wrapper.
+ * @post @c !(bool)*this
+ */
+ function() noexcept
+ : _Function_base() { }
+
+ /**
+ * @brief Creates an empty function call wrapper.
+ * @post @c !(bool)*this
+ */
+ function(nullptr_t) noexcept
+ : _Function_base() { }
+
+ /**
+ * @brief %Function copy constructor.
+ * @param __x A %function object with identical call signature.
+ * @post @c bool(*this) == bool(__x)
+ *
+ * The newly-created %function contains a copy of the target of @a
+ * __x (if it has one).
+ */
+ function(const function& __x);
+
+ /**
+ * @brief %Function move constructor.
+ * @param __x A %function object rvalue with identical call signature.
+ *
+ * The newly-created %function contains the target of @a __x
+ * (if it has one).
+ */
+ function(function&& __x) : _Function_base()
+ {
+ __x.swap(*this);
+ }
+
+ // TODO: needs allocator_arg_t
+
+ /**
+ * @brief Builds a %function that targets a copy of the incoming
+ * function object.
+ * @param __f A %function object that is callable with parameters of
+ * type @c T1, @c T2, ..., @c TN and returns a value convertible
+ * to @c Res.
+ *
+ * The newly-created %function object will target a copy of
+ * @a __f. If @a __f is @c reference_wrapper<F>, then this function
+ * object will contain a reference to the function object @c
+ * __f.get(). If @a __f is a NULL function pointer or NULL
+ * pointer-to-member, the newly-created object will be empty.
+ *
+ * If @a __f is a non-NULL function pointer or an object of type @c
+ * reference_wrapper<F>, this function will not throw.
+ */
+ template<typename _Functor,
+ typename = _Requires<_Callable<_Functor>, void>>
+ function(_Functor);
+
+ /**
+ * @brief %Function assignment operator.
+ * @param __x A %function with identical call signature.
+ * @post @c (bool)*this == (bool)x
+ * @returns @c *this
+ *
+ * The target of @a __x is copied to @c *this. If @a __x has no
+ * target, then @c *this will be empty.
+ *
+ * If @a __x targets a function pointer or a reference to a function
+ * object, then this operation will not throw an %exception.
+ */
+ function&
+ operator=(const function& __x)
+ {
+ function(__x).swap(*this);
+ return *this;
+ }
+
+ /**
+ * @brief %Function move-assignment operator.
+ * @param __x A %function rvalue with identical call signature.
+ * @returns @c *this
+ *
+ * The target of @a __x is moved to @c *this. If @a __x has no
+ * target, then @c *this will be empty.
+ *
+ * If @a __x targets a function pointer or a reference to a function
+ * object, then this operation will not throw an %exception.
+ */
+ function&
+ operator=(function&& __x)
+ {
+ function(std::move(__x)).swap(*this);
+ return *this;
+ }
+
+ /**
+ * @brief %Function assignment to zero.
+ * @post @c !(bool)*this
+ * @returns @c *this
+ *
+ * The target of @c *this is deallocated, leaving it empty.
+ */
+ function&
+ operator=(nullptr_t)
+ {
+ if (_M_manager)
+ {
+ _M_manager(_M_functor, _M_functor, __destroy_functor);
+ _M_manager = 0;
+ _M_invoker = 0;
+ }
+ return *this;
+ }
+
+ /**
+ * @brief %Function assignment to a new target.
+ * @param __f A %function object that is callable with parameters of
+ * type @c T1, @c T2, ..., @c TN and returns a value convertible
+ * to @c Res.
+ * @return @c *this
+ *
+ * This %function object wrapper will target a copy of @a
+ * __f. If @a __f is @c reference_wrapper<F>, then this function
+ * object will contain a reference to the function object @c
+ * __f.get(). If @a __f is a NULL function pointer or NULL
+ * pointer-to-member, @c this object will be empty.
+ *
+ * If @a __f is a non-NULL function pointer or an object of type @c
+ * reference_wrapper<F>, this function will not throw.
+ */
+ template<typename _Functor>
+ _Requires<_Callable<_Functor>, function&>
+ operator=(_Functor&& __f)
+ {
+ function(std::forward<_Functor>(__f)).swap(*this);
+ return *this;
+ }
+
+ /// @overload
+ template<typename _Functor>
+ function&
+ operator=(reference_wrapper<_Functor> __f) noexcept
+ {
+ function(__f).swap(*this);
+ return *this;
+ }
+
+ // [3.7.2.2] function modifiers
+
+ /**
+ * @brief Swap the targets of two %function objects.
+ * @param __x A %function with identical call signature.
+ *
+ * Swap the targets of @c this function object and @a __f. This
+ * function will not throw an %exception.
+ */
+ void swap(function& __x)
+ {
+ std::swap(_M_functor, __x._M_functor);
+ std::swap(_M_manager, __x._M_manager);
+ std::swap(_M_invoker, __x._M_invoker);
+ }
+
+ // TODO: needs allocator_arg_t
+ /*
+ template<typename _Functor, typename _Alloc>
+ void
+ assign(_Functor&& __f, const _Alloc& __a)
+ {
+ function(allocator_arg, __a,
+ std::forward<_Functor>(__f)).swap(*this);
+ }
+ */
+
+ // [3.7.2.3] function capacity
+
+ /**
+ * @brief Determine if the %function wrapper has a target.
+ *
+ * @return @c true when this %function object contains a target,
+ * or @c false when it is empty.
+ *
+ * This function will not throw an %exception.
+ */
+ explicit operator bool() const noexcept
+ { return !_M_empty(); }
+
+ // [3.7.2.4] function invocation
+
+ /**
+ * @brief Invokes the function targeted by @c *this.
+ * @returns the result of the target.
+ * @throws bad_function_call when @c !(bool)*this
+ *
+ * The function call operator invokes the target function object
+ * stored by @c this.
+ */
+ _Res operator()(_ArgTypes... __args) const;
+
+#ifdef __GXX_RTTI
+ // [3.7.2.5] function target access
+ /**
+ * @brief Determine the type of the target of this function object
+ * wrapper.
+ *
+ * @returns the type identifier of the target function object, or
+ * @c typeid(void) if @c !(bool)*this.
+ *
+ * This function will not throw an %exception.
+ */
+ const type_info& target_type() const noexcept;
+
+ /**
+ * @brief Access the stored target function object.
+ *
+ * @return Returns a pointer to the stored target function object,
+ * if @c typeid(Functor).equals(target_type()); otherwise, a NULL
+ * pointer.
+ *
+ * This function will not throw an %exception.
+ */
+ template<typename _Functor> _Functor* target() noexcept;
+
+ /// @overload
+ template<typename _Functor> const _Functor* target() const noexcept;
+#endif
+
+ private:
+ typedef _Res (*_Invoker_type)(const _Any_data&, _ArgTypes...);
+ _Invoker_type _M_invoker;
+ };
+
+ // Out-of-line member definitions.
+ template<typename _Res, typename... _ArgTypes>
+ function<_Res(_ArgTypes...)>::
+ function(const function& __x)
+ : _Function_base()
+ {
+ if (static_cast<bool>(__x))
+ {
+ _M_invoker = __x._M_invoker;
+ _M_manager = __x._M_manager;
+ __x._M_manager(_M_functor, __x._M_functor, __clone_functor);
+ }
+ }
+
+ template<typename _Res, typename... _ArgTypes>
+ template<typename _Functor, typename>
+ function<_Res(_ArgTypes...)>::
+ function(_Functor __f)
+ : _Function_base()
+ {
+ typedef _Function_handler<_Signature_type, _Functor> _My_handler;
+
+ if (_My_handler::_M_not_empty_function(__f))
+ {
+ _My_handler::_M_init_functor(_M_functor, std::move(__f));
+ _M_invoker = &_My_handler::_M_invoke;
+ _M_manager = &_My_handler::_M_manager;
+ }
+ }
+
+ template<typename _Res, typename... _ArgTypes>
+ _Res
+ function<_Res(_ArgTypes...)>::
+ operator()(_ArgTypes... __args) const
+ {
+ if (_M_empty())
+ __throw_bad_function_call();
+ return _M_invoker(_M_functor, std::forward<_ArgTypes>(__args)...);
+ }
+
+#ifdef __GXX_RTTI
+ template<typename _Res, typename... _ArgTypes>
+ const type_info&
+ function<_Res(_ArgTypes...)>::
+ target_type() const noexcept
+ {
+ if (_M_manager)
+ {
+ _Any_data __typeinfo_result;
+ _M_manager(__typeinfo_result, _M_functor, __get_type_info);
+ return *__typeinfo_result._M_access<const type_info*>();
+ }
+ else
+ return typeid(void);
+ }
+
+ template<typename _Res, typename... _ArgTypes>
+ template<typename _Functor>
+ _Functor*
+ function<_Res(_ArgTypes...)>::
+ target() noexcept
+ {
+ if (typeid(_Functor) == target_type() && _M_manager)
+ {
+ _Any_data __ptr;
+ if (_M_manager(__ptr, _M_functor, __get_functor_ptr)
+ && !is_const<_Functor>::value)
+ return 0;
+ else
+ return __ptr._M_access<_Functor*>();
+ }
+ else
+ return 0;
+ }
+
+ template<typename _Res, typename... _ArgTypes>
+ template<typename _Functor>
+ const _Functor*
+ function<_Res(_ArgTypes...)>::
+ target() const noexcept
+ {
+ if (typeid(_Functor) == target_type() && _M_manager)
+ {
+ _Any_data __ptr;
+ _M_manager(__ptr, _M_functor, __get_functor_ptr);
+ return __ptr._M_access<const _Functor*>();
+ }
+ else
+ return 0;
+ }
+#endif
+
+ // [20.7.15.2.6] null pointer comparisons
+
+ /**
+ * @brief Compares a polymorphic function object wrapper against 0
+ * (the NULL pointer).
+ * @returns @c true if the wrapper has no target, @c false otherwise
+ *
+ * This function will not throw an %exception.
+ */
+ template<typename _Res, typename... _Args>
+ inline bool
+ operator==(const function<_Res(_Args...)>& __f, nullptr_t) noexcept
+ { return !static_cast<bool>(__f); }
+
+ /// @overload
+ template<typename _Res, typename... _Args>
+ inline bool
+ operator==(nullptr_t, const function<_Res(_Args...)>& __f) noexcept
+ { return !static_cast<bool>(__f); }
+
+ /**
+ * @brief Compares a polymorphic function object wrapper against 0
+ * (the NULL pointer).
+ * @returns @c false if the wrapper has no target, @c true otherwise
+ *
+ * This function will not throw an %exception.
+ */
+ template<typename _Res, typename... _Args>
+ inline bool
+ operator!=(const function<_Res(_Args...)>& __f, nullptr_t) noexcept
+ { return static_cast<bool>(__f); }
+
+ /// @overload
+ template<typename _Res, typename... _Args>
+ inline bool
+ operator!=(nullptr_t, const function<_Res(_Args...)>& __f) noexcept
+ { return static_cast<bool>(__f); }
+
+ // [20.7.15.2.7] specialized algorithms
+
+ /**
+ * @brief Swap the targets of two polymorphic function object wrappers.
+ *
+ * This function will not throw an %exception.
+ */
+ template<typename _Res, typename... _Args>
+ inline void
+ swap(function<_Res(_Args...)>& __x, function<_Res(_Args...)>& __y)
+ { __x.swap(__y); }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+
+#endif // C++11
+
+#endif // _GLIBCXX_FUNCTIONAL
diff --git a/gcc-4.9/libstdc++-v3/include/std/future b/gcc-4.9/libstdc++-v3/include/std/future
new file mode 100644
index 0000000..717ce71
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/future
@@ -0,0 +1,1583 @@
+// <future> -*- C++ -*-
+
+// Copyright (C) 2009-2014 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/future
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_FUTURE
+#define _GLIBCXX_FUTURE 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <functional>
+#include <mutex>
+#include <thread>
+#include <condition_variable>
+#include <system_error>
+#include <atomic>
+#include <bits/functexcept.h>
+#include <bits/unique_ptr.h>
+#include <bits/shared_ptr.h>
+#include <bits/uses_allocator.h>
+#include <bits/alloc_traits.h>
+#include <ext/aligned_buffer.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @defgroup futures Futures
+ * @ingroup concurrency
+ *
+ * Classes for futures support.
+ * @{
+ */
+
+ /// Error code for futures
+ enum class future_errc
+ {
+ future_already_retrieved = 1,
+ promise_already_satisfied,
+ no_state,
+ broken_promise
+ };
+
+ /// Specialization.
+ template<>
+ struct is_error_code_enum<future_errc> : public true_type { };
+
+ /// Points to a statically-allocated object derived from error_category.
+ const error_category&
+ future_category() noexcept;
+
+ /// Overload for make_error_code.
+ inline error_code
+ make_error_code(future_errc __errc) noexcept
+ { return error_code(static_cast<int>(__errc), future_category()); }
+
+ /// Overload for make_error_condition.
+ inline error_condition
+ make_error_condition(future_errc __errc) noexcept
+ { return error_condition(static_cast<int>(__errc), future_category()); }
+
+ /**
+ * @brief Exception type thrown by futures.
+ * @ingroup exceptions
+ */
+ class future_error : public logic_error
+ {
+ error_code _M_code;
+
+ public:
+ explicit future_error(error_code __ec)
+ : logic_error("std::future_error"), _M_code(__ec)
+ { }
+
+ virtual ~future_error() noexcept;
+
+ virtual const char*
+ what() const noexcept;
+
+ const error_code&
+ code() const noexcept { return _M_code; }
+ };
+
+ // Forward declarations.
+ template<typename _Res>
+ class future;
+
+ template<typename _Res>
+ class shared_future;
+
+ template<typename _Signature>
+ class packaged_task;
+
+ template<typename _Res>
+ class promise;
+
+ /// Launch code for futures
+ enum class launch
+ {
+ async = 1,
+ deferred = 2
+ };
+
+ constexpr launch operator&(launch __x, launch __y)
+ {
+ return static_cast<launch>(
+ static_cast<int>(__x) & static_cast<int>(__y));
+ }
+
+ constexpr launch operator|(launch __x, launch __y)
+ {
+ return static_cast<launch>(
+ static_cast<int>(__x) | static_cast<int>(__y));
+ }
+
+ constexpr launch operator^(launch __x, launch __y)
+ {
+ return static_cast<launch>(
+ static_cast<int>(__x) ^ static_cast<int>(__y));
+ }
+
+ constexpr launch operator~(launch __x)
+ { return static_cast<launch>(~static_cast<int>(__x)); }
+
+ inline launch& operator&=(launch& __x, launch __y)
+ { return __x = __x & __y; }
+
+ inline launch& operator|=(launch& __x, launch __y)
+ { return __x = __x | __y; }
+
+ inline launch& operator^=(launch& __x, launch __y)
+ { return __x = __x ^ __y; }
+
+ /// Status code for futures
+ enum class future_status
+ {
+ ready,
+ timeout,
+ deferred
+ };
+
+ template<typename _Fn, typename... _Args>
+ future<typename result_of<_Fn(_Args...)>::type>
+ async(launch __policy, _Fn&& __fn, _Args&&... __args);
+
+ template<typename _Fn, typename... _Args>
+ future<typename result_of<_Fn(_Args...)>::type>
+ async(_Fn&& __fn, _Args&&... __args);
+
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
+ && (ATOMIC_INT_LOCK_FREE > 1)
+
+ /// Base class and enclosing scope.
+ struct __future_base
+ {
+ /// Base class for results.
+ struct _Result_base
+ {
+ exception_ptr _M_error;
+
+ _Result_base(const _Result_base&) = delete;
+ _Result_base& operator=(const _Result_base&) = delete;
+
+ // _M_destroy() allows derived classes to control deallocation
+ virtual void _M_destroy() = 0;
+
+ struct _Deleter
+ {
+ void operator()(_Result_base* __fr) const { __fr->_M_destroy(); }
+ };
+
+ protected:
+ _Result_base();
+ virtual ~_Result_base();
+ };
+
+ /// Result.
+ template<typename _Res>
+ struct _Result : _Result_base
+ {
+ private:
+ __gnu_cxx::__aligned_buffer<_Res> _M_storage;
+ bool _M_initialized;
+
+ public:
+ typedef _Res result_type;
+
+ _Result() noexcept : _M_initialized() { }
+
+ ~_Result()
+ {
+ if (_M_initialized)
+ _M_value().~_Res();
+ }
+
+ // Return lvalue, future will add const or rvalue-reference
+ _Res&
+ _M_value() noexcept { return *_M_storage._M_ptr(); }
+
+ void
+ _M_set(const _Res& __res)
+ {
+ ::new (_M_storage._M_addr()) _Res(__res);
+ _M_initialized = true;
+ }
+
+ void
+ _M_set(_Res&& __res)
+ {
+ ::new (_M_storage._M_addr()) _Res(std::move(__res));
+ _M_initialized = true;
+ }
+
+ private:
+ void _M_destroy() { delete this; }
+ };
+
+ /// A unique_ptr based on the instantiating type.
+ template<typename _Res>
+ using _Ptr = unique_ptr<_Res, _Result_base::_Deleter>;
+
+ /// Result_alloc.
+ template<typename _Res, typename _Alloc>
+ struct _Result_alloc final : _Result<_Res>, _Alloc
+ {
+ typedef typename allocator_traits<_Alloc>::template
+ rebind_alloc<_Result_alloc> __allocator_type;
+
+ explicit
+ _Result_alloc(const _Alloc& __a) : _Result<_Res>(), _Alloc(__a)
+ { }
+
+ private:
+ void _M_destroy()
+ {
+ typedef allocator_traits<__allocator_type> __traits;
+ __allocator_type __a(*this);
+ __traits::destroy(__a, this);
+ __traits::deallocate(__a, this, 1);
+ }
+ };
+
+ template<typename _Res, typename _Allocator>
+ static _Ptr<_Result_alloc<_Res, _Allocator>>
+ _S_allocate_result(const _Allocator& __a)
+ {
+ typedef _Result_alloc<_Res, _Allocator> __result_type;
+ typedef allocator_traits<typename __result_type::__allocator_type>
+ __traits;
+ typename __traits::allocator_type __a2(__a);
+ __result_type* __p = __traits::allocate(__a2, 1);
+ __try
+ {
+ __traits::construct(__a2, __p, __a);
+ }
+ __catch(...)
+ {
+ __traits::deallocate(__a2, __p, 1);
+ __throw_exception_again;
+ }
+ return _Ptr<__result_type>(__p);
+ }
+
+ template<typename _Res, typename _Tp>
+ static _Ptr<_Result<_Res>>
+ _S_allocate_result(const std::allocator<_Tp>& __a)
+ {
+ return _Ptr<_Result<_Res>>(new _Result<_Res>);
+ }
+
+ /// Base class for state between a promise and one or more
+ /// associated futures.
+ class _State_baseV2
+ {
+ typedef _Ptr<_Result_base> _Ptr_type;
+
+ _Ptr_type _M_result;
+ mutex _M_mutex;
+ condition_variable _M_cond;
+ atomic_flag _M_retrieved;
+ once_flag _M_once;
+
+ public:
+ _State_baseV2() noexcept : _M_result(), _M_retrieved(ATOMIC_FLAG_INIT)
+ { }
+ _State_baseV2(const _State_baseV2&) = delete;
+ _State_baseV2& operator=(const _State_baseV2&) = delete;
+ virtual ~_State_baseV2() = default;
+
+ _Result_base&
+ wait()
+ {
+ _M_complete_async();
+ unique_lock<mutex> __lock(_M_mutex);
+ _M_cond.wait(__lock, [&] { return _M_ready(); });
+ return *_M_result;
+ }
+
+ template<typename _Rep, typename _Period>
+ future_status
+ wait_for(const chrono::duration<_Rep, _Period>& __rel)
+ {
+ unique_lock<mutex> __lock(_M_mutex);
+ if (_M_ready())
+ return future_status::ready;
+ if (_M_has_deferred())
+ return future_status::deferred;
+ if (_M_cond.wait_for(__lock, __rel, [&] { return _M_ready(); }))
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2100. timed waiting functions must also join
+ _M_complete_async();
+ return future_status::ready;
+ }
+ return future_status::timeout;
+ }
+
+ template<typename _Clock, typename _Duration>
+ future_status
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs)
+ {
+ unique_lock<mutex> __lock(_M_mutex);
+ if (_M_ready())
+ return future_status::ready;
+ if (_M_has_deferred())
+ return future_status::deferred;
+ if (_M_cond.wait_until(__lock, __abs, [&] { return _M_ready(); }))
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2100. timed waiting functions must also join
+ _M_complete_async();
+ return future_status::ready;
+ }
+ return future_status::timeout;
+ }
+
+ void
+ _M_set_result(function<_Ptr_type()> __res, bool __ignore_failure = false)
+ {
+ bool __set = __ignore_failure;
+ // all calls to this function are serialized,
+ // side-effects of invoking __res only happen once
+ call_once(_M_once, &_State_baseV2::_M_do_set, this, ref(__res),
+ ref(__set));
+ if (!__set)
+ __throw_future_error(int(future_errc::promise_already_satisfied));
+ }
+
+ void
+ _M_break_promise(_Ptr_type __res)
+ {
+ if (static_cast<bool>(__res))
+ {
+ error_code __ec(make_error_code(future_errc::broken_promise));
+ __res->_M_error = make_exception_ptr(future_error(__ec));
+ {
+ lock_guard<mutex> __lock(_M_mutex);
+ _M_result.swap(__res);
+ }
+ _M_cond.notify_all();
+ }
+ }
+
+ // Called when this object is passed to a future.
+ void
+ _M_set_retrieved_flag()
+ {
+ if (_M_retrieved.test_and_set())
+ __throw_future_error(int(future_errc::future_already_retrieved));
+ }
+
+ template<typename _Res, typename _Arg>
+ struct _Setter;
+
+ // set lvalues
+ template<typename _Res, typename _Arg>
+ struct _Setter<_Res, _Arg&>
+ {
+ // check this is only used by promise<R>::set_value(const R&)
+ // or promise<R>::set_value(R&)
+ static_assert(is_same<_Res, _Arg&>::value // promise<R&>
+ || is_same<const _Res, _Arg>::value, // promise<R>
+ "Invalid specialisation");
+
+ typename promise<_Res>::_Ptr_type operator()()
+ {
+ _State_baseV2::_S_check(_M_promise->_M_future);
+ _M_promise->_M_storage->_M_set(_M_arg);
+ return std::move(_M_promise->_M_storage);
+ }
+ promise<_Res>* _M_promise;
+ _Arg& _M_arg;
+ };
+
+ // set rvalues
+ template<typename _Res>
+ struct _Setter<_Res, _Res&&>
+ {
+ typename promise<_Res>::_Ptr_type operator()()
+ {
+ _State_baseV2::_S_check(_M_promise->_M_future);
+ _M_promise->_M_storage->_M_set(std::move(_M_arg));
+ return std::move(_M_promise->_M_storage);
+ }
+ promise<_Res>* _M_promise;
+ _Res& _M_arg;
+ };
+
+ struct __exception_ptr_tag { };
+
+ // set exceptions
+ template<typename _Res>
+ struct _Setter<_Res, __exception_ptr_tag>
+ {
+ typename promise<_Res>::_Ptr_type operator()()
+ {
+ _State_baseV2::_S_check(_M_promise->_M_future);
+ _M_promise->_M_storage->_M_error = _M_ex;
+ return std::move(_M_promise->_M_storage);
+ }
+
+ promise<_Res>* _M_promise;
+ exception_ptr& _M_ex;
+ };
+
+ template<typename _Res, typename _Arg>
+ static _Setter<_Res, _Arg&&>
+ __setter(promise<_Res>* __prom, _Arg&& __arg)
+ {
+ return _Setter<_Res, _Arg&&>{ __prom, __arg };
+ }
+
+ template<typename _Res>
+ static _Setter<_Res, __exception_ptr_tag>
+ __setter(exception_ptr& __ex, promise<_Res>* __prom)
+ {
+ return _Setter<_Res, __exception_ptr_tag>{ __prom, __ex };
+ }
+
+ static _Setter<void, void>
+ __setter(promise<void>* __prom);
+
+ template<typename _Tp>
+ static void
+ _S_check(const shared_ptr<_Tp>& __p)
+ {
+ if (!static_cast<bool>(__p))
+ __throw_future_error((int)future_errc::no_state);
+ }
+
+ private:
+ void
+ _M_do_set(function<_Ptr_type()>& __f, bool& __set)
+ {
+ _Ptr_type __res = __f();
+ {
+ lock_guard<mutex> __lock(_M_mutex);
+ _M_result.swap(__res);
+ }
+ _M_cond.notify_all();
+ __set = true;
+ }
+
+ bool _M_ready() const noexcept { return static_cast<bool>(_M_result); }
+
+ // Wait for completion of async function.
+ virtual void _M_complete_async() { }
+
+ // Return true if state contains a deferred function.
+ virtual bool _M_has_deferred() const { return false; }
+ };
+
+#ifdef _GLIBCXX_ASYNC_ABI_COMPAT
+ class _State_base;
+ class _Async_state_common;
+#else
+ using _State_base = _State_baseV2;
+ class _Async_state_commonV2;
+#endif
+
+ template<typename _BoundFn, typename = typename _BoundFn::result_type>
+ class _Deferred_state;
+
+ template<typename _BoundFn, typename = typename _BoundFn::result_type>
+ class _Async_state_impl;
+
+ template<typename _Signature>
+ class _Task_state_base;
+
+ template<typename _Fn, typename _Alloc, typename _Signature>
+ class _Task_state;
+
+ template<typename _BoundFn>
+ static std::shared_ptr<_State_base>
+ _S_make_deferred_state(_BoundFn&& __fn);
+
+ template<typename _BoundFn>
+ static std::shared_ptr<_State_base>
+ _S_make_async_state(_BoundFn&& __fn);
+
+ template<typename _Res_ptr,
+ typename _Res = typename _Res_ptr::element_type::result_type>
+ struct _Task_setter;
+
+ template<typename _Res_ptr, typename _BoundFn>
+ static _Task_setter<_Res_ptr>
+ _S_task_setter(_Res_ptr& __ptr, _BoundFn&& __call)
+ {
+ return _Task_setter<_Res_ptr>{ __ptr, std::ref(__call) };
+ }
+ };
+
+ /// Partial specialization for reference types.
+ template<typename _Res>
+ struct __future_base::_Result<_Res&> : __future_base::_Result_base
+ {
+ typedef _Res& result_type;
+
+ _Result() noexcept : _M_value_ptr() { }
+
+ void _M_set(_Res& __res) noexcept { _M_value_ptr = &__res; }
+
+ _Res& _M_get() noexcept { return *_M_value_ptr; }
+
+ private:
+ _Res* _M_value_ptr;
+
+ void _M_destroy() { delete this; }
+ };
+
+ /// Explicit specialization for void.
+ template<>
+ struct __future_base::_Result<void> : __future_base::_Result_base
+ {
+ typedef void result_type;
+
+ private:
+ void _M_destroy() { delete this; }
+ };
+
+#ifndef _GLIBCXX_ASYNC_ABI_COMPAT
+
+ /// Common implementation for future and shared_future.
+ template<typename _Res>
+ class __basic_future : public __future_base
+ {
+ protected:
+ typedef shared_ptr<_State_base> __state_type;
+ typedef __future_base::_Result<_Res>& __result_type;
+
+ private:
+ __state_type _M_state;
+
+ public:
+ // Disable copying.
+ __basic_future(const __basic_future&) = delete;
+ __basic_future& operator=(const __basic_future&) = delete;
+
+ bool
+ valid() const noexcept { return static_cast<bool>(_M_state); }
+
+ void
+ wait() const
+ {
+ _State_base::_S_check(_M_state);
+ _M_state->wait();
+ }
+
+ template<typename _Rep, typename _Period>
+ future_status
+ wait_for(const chrono::duration<_Rep, _Period>& __rel) const
+ {
+ _State_base::_S_check(_M_state);
+ return _M_state->wait_for(__rel);
+ }
+
+ template<typename _Clock, typename _Duration>
+ future_status
+ wait_until(const chrono::time_point<_Clock, _Duration>& __abs) const
+ {
+ _State_base::_S_check(_M_state);
+ return _M_state->wait_until(__abs);
+ }
+
+ protected:
+ /// Wait for the state to be ready and rethrow any stored exception
+ __result_type
+ _M_get_result() const
+ {
+ _State_base::_S_check(_M_state);
+ _Result_base& __res = _M_state->wait();
+ if (!(__res._M_error == 0))
+ rethrow_exception(__res._M_error);
+ return static_cast<__result_type>(__res);
+ }
+
+ void _M_swap(__basic_future& __that) noexcept
+ {
+ _M_state.swap(__that._M_state);
+ }
+
+ // Construction of a future by promise::get_future()
+ explicit
+ __basic_future(const __state_type& __state) : _M_state(__state)
+ {
+ _State_base::_S_check(_M_state);
+ _M_state->_M_set_retrieved_flag();
+ }
+
+ // Copy construction from a shared_future
+ explicit
+ __basic_future(const shared_future<_Res>&) noexcept;
+
+ // Move construction from a shared_future
+ explicit
+ __basic_future(shared_future<_Res>&&) noexcept;
+
+ // Move construction from a future
+ explicit
+ __basic_future(future<_Res>&&) noexcept;
+
+ constexpr __basic_future() noexcept : _M_state() { }
+
+ struct _Reset
+ {
+ explicit _Reset(__basic_future& __fut) noexcept : _M_fut(__fut) { }
+ ~_Reset() { _M_fut._M_state.reset(); }
+ __basic_future& _M_fut;
+ };
+ };
+
+
+ /// Primary template for future.
+ template<typename _Res>
+ class future : public __basic_future<_Res>
+ {
+ friend class promise<_Res>;
+ template<typename> friend class packaged_task;
+ template<typename _Fn, typename... _Args>
+ friend future<typename result_of<_Fn(_Args...)>::type>
+ async(launch, _Fn&&, _Args&&...);
+
+ typedef __basic_future<_Res> _Base_type;
+ typedef typename _Base_type::__state_type __state_type;
+
+ explicit
+ future(const __state_type& __state) : _Base_type(__state) { }
+
+ public:
+ constexpr future() noexcept : _Base_type() { }
+
+ /// Move constructor
+ future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
+
+ // Disable copying
+ future(const future&) = delete;
+ future& operator=(const future&) = delete;
+
+ future& operator=(future&& __fut) noexcept
+ {
+ future(std::move(__fut))._M_swap(*this);
+ return *this;
+ }
+
+ /// Retrieving the value
+ _Res
+ get()
+ {
+ typename _Base_type::_Reset __reset(*this);
+ return std::move(this->_M_get_result()._M_value());
+ }
+
+ shared_future<_Res> share();
+ };
+
+ /// Partial specialization for future<R&>
+ template<typename _Res>
+ class future<_Res&> : public __basic_future<_Res&>
+ {
+ friend class promise<_Res&>;
+ template<typename> friend class packaged_task;
+ template<typename _Fn, typename... _Args>
+ friend future<typename result_of<_Fn(_Args...)>::type>
+ async(launch, _Fn&&, _Args&&...);
+
+ typedef __basic_future<_Res&> _Base_type;
+ typedef typename _Base_type::__state_type __state_type;
+
+ explicit
+ future(const __state_type& __state) : _Base_type(__state) { }
+
+ public:
+ constexpr future() noexcept : _Base_type() { }
+
+ /// Move constructor
+ future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
+
+ // Disable copying
+ future(const future&) = delete;
+ future& operator=(const future&) = delete;
+
+ future& operator=(future&& __fut) noexcept
+ {
+ future(std::move(__fut))._M_swap(*this);
+ return *this;
+ }
+
+ /// Retrieving the value
+ _Res&
+ get()
+ {
+ typename _Base_type::_Reset __reset(*this);
+ return this->_M_get_result()._M_get();
+ }
+
+ shared_future<_Res&> share();
+ };
+
+ /// Explicit specialization for future<void>
+ template<>
+ class future<void> : public __basic_future<void>
+ {
+ friend class promise<void>;
+ template<typename> friend class packaged_task;
+ template<typename _Fn, typename... _Args>
+ friend future<typename result_of<_Fn(_Args...)>::type>
+ async(launch, _Fn&&, _Args&&...);
+
+ typedef __basic_future<void> _Base_type;
+ typedef typename _Base_type::__state_type __state_type;
+
+ explicit
+ future(const __state_type& __state) : _Base_type(__state) { }
+
+ public:
+ constexpr future() noexcept : _Base_type() { }
+
+ /// Move constructor
+ future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { }
+
+ // Disable copying
+ future(const future&) = delete;
+ future& operator=(const future&) = delete;
+
+ future& operator=(future&& __fut) noexcept
+ {
+ future(std::move(__fut))._M_swap(*this);
+ return *this;
+ }
+
+ /// Retrieving the value
+ void
+ get()
+ {
+ typename _Base_type::_Reset __reset(*this);
+ this->_M_get_result();
+ }
+
+ shared_future<void> share();
+ };
+
+
+ /// Primary template for shared_future.
+ template<typename _Res>
+ class shared_future : public __basic_future<_Res>
+ {
+ typedef __basic_future<_Res> _Base_type;
+
+ public:
+ constexpr shared_future() noexcept : _Base_type() { }
+
+ /// Copy constructor
+ shared_future(const shared_future& __sf) : _Base_type(__sf) { }
+
+ /// Construct from a future rvalue
+ shared_future(future<_Res>&& __uf) noexcept
+ : _Base_type(std::move(__uf))
+ { }
+
+ /// Construct from a shared_future rvalue
+ shared_future(shared_future&& __sf) noexcept
+ : _Base_type(std::move(__sf))
+ { }
+
+ shared_future& operator=(const shared_future& __sf)
+ {
+ shared_future(__sf)._M_swap(*this);
+ return *this;
+ }
+
+ shared_future& operator=(shared_future&& __sf) noexcept
+ {
+ shared_future(std::move(__sf))._M_swap(*this);
+ return *this;
+ }
+
+ /// Retrieving the value
+ const _Res&
+ get() const { return this->_M_get_result()._M_value(); }
+ };
+
+ /// Partial specialization for shared_future<R&>
+ template<typename _Res>
+ class shared_future<_Res&> : public __basic_future<_Res&>
+ {
+ typedef __basic_future<_Res&> _Base_type;
+
+ public:
+ constexpr shared_future() noexcept : _Base_type() { }
+
+ /// Copy constructor
+ shared_future(const shared_future& __sf) : _Base_type(__sf) { }
+
+ /// Construct from a future rvalue
+ shared_future(future<_Res&>&& __uf) noexcept
+ : _Base_type(std::move(__uf))
+ { }
+
+ /// Construct from a shared_future rvalue
+ shared_future(shared_future&& __sf) noexcept
+ : _Base_type(std::move(__sf))
+ { }
+
+ shared_future& operator=(const shared_future& __sf)
+ {
+ shared_future(__sf)._M_swap(*this);
+ return *this;
+ }
+
+ shared_future& operator=(shared_future&& __sf) noexcept
+ {
+ shared_future(std::move(__sf))._M_swap(*this);
+ return *this;
+ }
+
+ /// Retrieving the value
+ _Res&
+ get() const { return this->_M_get_result()._M_get(); }
+ };
+
+ /// Explicit specialization for shared_future<void>
+ template<>
+ class shared_future<void> : public __basic_future<void>
+ {
+ typedef __basic_future<void> _Base_type;
+
+ public:
+ constexpr shared_future() noexcept : _Base_type() { }
+
+ /// Copy constructor
+ shared_future(const shared_future& __sf) : _Base_type(__sf) { }
+
+ /// Construct from a future rvalue
+ shared_future(future<void>&& __uf) noexcept
+ : _Base_type(std::move(__uf))
+ { }
+
+ /// Construct from a shared_future rvalue
+ shared_future(shared_future&& __sf) noexcept
+ : _Base_type(std::move(__sf))
+ { }
+
+ shared_future& operator=(const shared_future& __sf)
+ {
+ shared_future(__sf)._M_swap(*this);
+ return *this;
+ }
+
+ shared_future& operator=(shared_future&& __sf) noexcept
+ {
+ shared_future(std::move(__sf))._M_swap(*this);
+ return *this;
+ }
+
+ // Retrieving the value
+ void
+ get() const { this->_M_get_result(); }
+ };
+
+ // Now we can define the protected __basic_future constructors.
+ template<typename _Res>
+ inline __basic_future<_Res>::
+ __basic_future(const shared_future<_Res>& __sf) noexcept
+ : _M_state(__sf._M_state)
+ { }
+
+ template<typename _Res>
+ inline __basic_future<_Res>::
+ __basic_future(shared_future<_Res>&& __sf) noexcept
+ : _M_state(std::move(__sf._M_state))
+ { }
+
+ template<typename _Res>
+ inline __basic_future<_Res>::
+ __basic_future(future<_Res>&& __uf) noexcept
+ : _M_state(std::move(__uf._M_state))
+ { }
+
+ template<typename _Res>
+ inline shared_future<_Res>
+ future<_Res>::share()
+ { return shared_future<_Res>(std::move(*this)); }
+
+ template<typename _Res>
+ inline shared_future<_Res&>
+ future<_Res&>::share()
+ { return shared_future<_Res&>(std::move(*this)); }
+
+ inline shared_future<void>
+ future<void>::share()
+ { return shared_future<void>(std::move(*this)); }
+
+ /// Primary template for promise
+ template<typename _Res>
+ class promise
+ {
+ typedef __future_base::_State_base _State;
+ typedef __future_base::_Result<_Res> _Res_type;
+ typedef __future_base::_Ptr<_Res_type> _Ptr_type;
+ template<typename, typename> friend class _State::_Setter;
+
+ shared_ptr<_State> _M_future;
+ _Ptr_type _M_storage;
+
+ public:
+ promise()
+ : _M_future(std::make_shared<_State>()),
+ _M_storage(new _Res_type())
+ { }
+
+ promise(promise&& __rhs) noexcept
+ : _M_future(std::move(__rhs._M_future)),
+ _M_storage(std::move(__rhs._M_storage))
+ { }
+
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator& __a)
+ : _M_future(std::allocate_shared<_State>(__a)),
+ _M_storage(__future_base::_S_allocate_result<_Res>(__a))
+ { }
+
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
+ : _M_future(std::move(__rhs._M_future)),
+ _M_storage(std::move(__rhs._M_storage))
+ { }
+
+ promise(const promise&) = delete;
+
+ ~promise()
+ {
+ if (static_cast<bool>(_M_future) && !_M_future.unique())
+ _M_future->_M_break_promise(std::move(_M_storage));
+ }
+
+ // Assignment
+ promise&
+ operator=(promise&& __rhs) noexcept
+ {
+ promise(std::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ promise& operator=(const promise&) = delete;
+
+ void
+ swap(promise& __rhs) noexcept
+ {
+ _M_future.swap(__rhs._M_future);
+ _M_storage.swap(__rhs._M_storage);
+ }
+
+ // Retrieving the result
+ future<_Res>
+ get_future()
+ { return future<_Res>(_M_future); }
+
+ // Setting the result
+ void
+ set_value(const _Res& __r)
+ {
+ auto __setter = _State::__setter(this, __r);
+ _M_future->_M_set_result(std::move(__setter));
+ }
+
+ void
+ set_value(_Res&& __r)
+ {
+ auto __setter = _State::__setter(this, std::move(__r));
+ _M_future->_M_set_result(std::move(__setter));
+ }
+
+ void
+ set_exception(exception_ptr __p)
+ {
+ auto __setter = _State::__setter(__p, this);
+ _M_future->_M_set_result(std::move(__setter));
+ }
+ };
+
+ template<typename _Res>
+ inline void
+ swap(promise<_Res>& __x, promise<_Res>& __y) noexcept
+ { __x.swap(__y); }
+
+ template<typename _Res, typename _Alloc>
+ struct uses_allocator<promise<_Res>, _Alloc>
+ : public true_type { };
+
+
+ /// Partial specialization for promise<R&>
+ template<typename _Res>
+ class promise<_Res&>
+ {
+ typedef __future_base::_State_base _State;
+ typedef __future_base::_Result<_Res&> _Res_type;
+ typedef __future_base::_Ptr<_Res_type> _Ptr_type;
+ template<typename, typename> friend class _State::_Setter;
+
+ shared_ptr<_State> _M_future;
+ _Ptr_type _M_storage;
+
+ public:
+ promise()
+ : _M_future(std::make_shared<_State>()),
+ _M_storage(new _Res_type())
+ { }
+
+ promise(promise&& __rhs) noexcept
+ : _M_future(std::move(__rhs._M_future)),
+ _M_storage(std::move(__rhs._M_storage))
+ { }
+
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator& __a)
+ : _M_future(std::allocate_shared<_State>(__a)),
+ _M_storage(__future_base::_S_allocate_result<_Res&>(__a))
+ { }
+
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
+ : _M_future(std::move(__rhs._M_future)),
+ _M_storage(std::move(__rhs._M_storage))
+ { }
+
+ promise(const promise&) = delete;
+
+ ~promise()
+ {
+ if (static_cast<bool>(_M_future) && !_M_future.unique())
+ _M_future->_M_break_promise(std::move(_M_storage));
+ }
+
+ // Assignment
+ promise&
+ operator=(promise&& __rhs) noexcept
+ {
+ promise(std::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ promise& operator=(const promise&) = delete;
+
+ void
+ swap(promise& __rhs) noexcept
+ {
+ _M_future.swap(__rhs._M_future);
+ _M_storage.swap(__rhs._M_storage);
+ }
+
+ // Retrieving the result
+ future<_Res&>
+ get_future()
+ { return future<_Res&>(_M_future); }
+
+ // Setting the result
+ void
+ set_value(_Res& __r)
+ {
+ auto __setter = _State::__setter(this, __r);
+ _M_future->_M_set_result(std::move(__setter));
+ }
+
+ void
+ set_exception(exception_ptr __p)
+ {
+ auto __setter = _State::__setter(__p, this);
+ _M_future->_M_set_result(std::move(__setter));
+ }
+ };
+
+ /// Explicit specialization for promise<void>
+ template<>
+ class promise<void>
+ {
+ typedef __future_base::_State_base _State;
+ typedef __future_base::_Result<void> _Res_type;
+ typedef __future_base::_Ptr<_Res_type> _Ptr_type;
+ template<typename, typename> friend class _State::_Setter;
+
+ shared_ptr<_State> _M_future;
+ _Ptr_type _M_storage;
+
+ public:
+ promise()
+ : _M_future(std::make_shared<_State>()),
+ _M_storage(new _Res_type())
+ { }
+
+ promise(promise&& __rhs) noexcept
+ : _M_future(std::move(__rhs._M_future)),
+ _M_storage(std::move(__rhs._M_storage))
+ { }
+
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator& __a)
+ : _M_future(std::allocate_shared<_State>(__a)),
+ _M_storage(__future_base::_S_allocate_result<void>(__a))
+ { }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2095. missing constructors needed for uses-allocator construction
+ template<typename _Allocator>
+ promise(allocator_arg_t, const _Allocator&, promise&& __rhs)
+ : _M_future(std::move(__rhs._M_future)),
+ _M_storage(std::move(__rhs._M_storage))
+ { }
+
+ promise(const promise&) = delete;
+
+ ~promise()
+ {
+ if (static_cast<bool>(_M_future) && !_M_future.unique())
+ _M_future->_M_break_promise(std::move(_M_storage));
+ }
+
+ // Assignment
+ promise&
+ operator=(promise&& __rhs) noexcept
+ {
+ promise(std::move(__rhs)).swap(*this);
+ return *this;
+ }
+
+ promise& operator=(const promise&) = delete;
+
+ void
+ swap(promise& __rhs) noexcept
+ {
+ _M_future.swap(__rhs._M_future);
+ _M_storage.swap(__rhs._M_storage);
+ }
+
+ // Retrieving the result
+ future<void>
+ get_future()
+ { return future<void>(_M_future); }
+
+ // Setting the result
+ void set_value();
+
+ void
+ set_exception(exception_ptr __p)
+ {
+ auto __setter = _State::__setter(__p, this);
+ _M_future->_M_set_result(std::move(__setter));
+ }
+ };
+
+ // set void
+ template<>
+ struct __future_base::_State_base::_Setter<void, void>
+ {
+ promise<void>::_Ptr_type operator()()
+ {
+ _State_base::_S_check(_M_promise->_M_future);
+ return std::move(_M_promise->_M_storage);
+ }
+
+ promise<void>* _M_promise;
+ };
+
+ inline __future_base::_State_base::_Setter<void, void>
+ __future_base::_State_base::__setter(promise<void>* __prom)
+ {
+ return _Setter<void, void>{ __prom };
+ }
+
+ inline void
+ promise<void>::set_value()
+ {
+ auto __setter = _State::__setter(this);
+ _M_future->_M_set_result(std::move(__setter));
+ }
+
+
+ template<typename _Ptr_type, typename _Res>
+ struct __future_base::_Task_setter
+ {
+ _Ptr_type operator()()
+ {
+ __try
+ {
+ _M_result->_M_set(_M_fn());
+ }
+ __catch(...)
+ {
+ _M_result->_M_error = current_exception();
+ }
+ return std::move(_M_result);
+ }
+ _Ptr_type& _M_result;
+ std::function<_Res()> _M_fn;
+ };
+
+ template<typename _Ptr_type>
+ struct __future_base::_Task_setter<_Ptr_type, void>
+ {
+ _Ptr_type operator()()
+ {
+ __try
+ {
+ _M_fn();
+ }
+ __catch(...)
+ {
+ _M_result->_M_error = current_exception();
+ }
+ return std::move(_M_result);
+ }
+ _Ptr_type& _M_result;
+ std::function<void()> _M_fn;
+ };
+
+ template<typename _Res, typename... _Args>
+ struct __future_base::_Task_state_base<_Res(_Args...)>
+ : __future_base::_State_base
+ {
+ typedef _Res _Res_type;
+
+ template<typename _Alloc>
+ _Task_state_base(const _Alloc& __a)
+ : _M_result(_S_allocate_result<_Res>(__a))
+ { }
+
+ virtual void
+ _M_run(_Args... __args) = 0;
+
+ virtual shared_ptr<_Task_state_base>
+ _M_reset() = 0;
+
+ typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
+ _Ptr_type _M_result;
+ };
+
+ template<typename _Fn, typename _Alloc, typename _Res, typename... _Args>
+ struct __future_base::_Task_state<_Fn, _Alloc, _Res(_Args...)> final
+ : __future_base::_Task_state_base<_Res(_Args...)>
+ {
+ template<typename _Fn2>
+ _Task_state(_Fn2&& __fn, const _Alloc& __a)
+ : _Task_state_base<_Res(_Args...)>(__a),
+ _M_impl(std::forward<_Fn2>(__fn), __a)
+ { }
+
+ private:
+ virtual void
+ _M_run(_Args... __args)
+ {
+ // bound arguments decay so wrap lvalue references
+ auto __boundfn = std::__bind_simple(std::ref(_M_impl._M_fn),
+ _S_maybe_wrap_ref(std::forward<_Args>(__args))...);
+ auto __setter = _S_task_setter(this->_M_result, std::move(__boundfn));
+ this->_M_set_result(std::move(__setter));
+ }
+
+ virtual shared_ptr<_Task_state_base<_Res(_Args...)>>
+ _M_reset();
+
+ template<typename _Tp>
+ static reference_wrapper<_Tp>
+ _S_maybe_wrap_ref(_Tp& __t)
+ { return std::ref(__t); }
+
+ template<typename _Tp>
+ static
+ typename enable_if<!is_lvalue_reference<_Tp>::value, _Tp>::type&&
+ _S_maybe_wrap_ref(_Tp&& __t)
+ { return std::forward<_Tp>(__t); }
+
+ struct _Impl : _Alloc
+ {
+ template<typename _Fn2>
+ _Impl(_Fn2&& __fn, const _Alloc& __a)
+ : _Alloc(__a), _M_fn(std::forward<_Fn2>(__fn)) { }
+ _Fn _M_fn;
+ } _M_impl;
+ };
+
+ template<typename _Signature, typename _Fn, typename _Alloc>
+ static shared_ptr<__future_base::_Task_state_base<_Signature>>
+ __create_task_state(_Fn&& __fn, const _Alloc& __a)
+ {
+ typedef typename decay<_Fn>::type _Fn2;
+ typedef __future_base::_Task_state<_Fn2, _Alloc, _Signature> _State;
+ return std::allocate_shared<_State>(__a, std::forward<_Fn>(__fn), __a);
+ }
+
+ template<typename _Fn, typename _Alloc, typename _Res, typename... _Args>
+ shared_ptr<__future_base::_Task_state_base<_Res(_Args...)>>
+ __future_base::_Task_state<_Fn, _Alloc, _Res(_Args...)>::_M_reset()
+ {
+ return __create_task_state<_Res(_Args...)>(std::move(_M_impl._M_fn),
+ static_cast<_Alloc&>(_M_impl));
+ }
+
+ template<typename _Task, typename _Fn, bool
+ = is_same<_Task, typename decay<_Fn>::type>::value>
+ struct __constrain_pkgdtask
+ { typedef void __type; };
+
+ template<typename _Task, typename _Fn>
+ struct __constrain_pkgdtask<_Task, _Fn, true>
+ { };
+
+ /// packaged_task
+ template<typename _Res, typename... _ArgTypes>
+ class packaged_task<_Res(_ArgTypes...)>
+ {
+ typedef __future_base::_Task_state_base<_Res(_ArgTypes...)> _State_type;
+ shared_ptr<_State_type> _M_state;
+
+ public:
+ // Construction and destruction
+ packaged_task() noexcept { }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2095. missing constructors needed for uses-allocator construction
+ template<typename _Allocator>
+ packaged_task(allocator_arg_t, const _Allocator& __a) noexcept
+ { }
+
+ template<typename _Fn, typename = typename
+ __constrain_pkgdtask<packaged_task, _Fn>::__type>
+ explicit
+ packaged_task(_Fn&& __fn)
+ : packaged_task(allocator_arg, std::allocator<int>(),
+ std::forward<_Fn>(__fn))
+ { }
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2097. packaged_task constructors should be constrained
+ template<typename _Fn, typename _Alloc, typename = typename
+ __constrain_pkgdtask<packaged_task, _Fn>::__type>
+ explicit
+ packaged_task(allocator_arg_t, const _Alloc& __a, _Fn&& __fn)
+ : _M_state(__create_task_state<_Res(_ArgTypes...)>(
+ std::forward<_Fn>(__fn), __a))
+ { }
+
+ ~packaged_task()
+ {
+ if (static_cast<bool>(_M_state) && !_M_state.unique())
+ _M_state->_M_break_promise(std::move(_M_state->_M_result));
+ }
+
+ // No copy
+ packaged_task(const packaged_task&) = delete;
+ packaged_task& operator=(const packaged_task&) = delete;
+
+ template<typename _Allocator>
+ packaged_task(allocator_arg_t, const _Allocator&,
+ const packaged_task&) = delete;
+
+ // Move support
+ packaged_task(packaged_task&& __other) noexcept
+ { this->swap(__other); }
+
+ template<typename _Allocator>
+ packaged_task(allocator_arg_t, const _Allocator&,
+ packaged_task&& __other) noexcept
+ { this->swap(__other); }
+
+ packaged_task& operator=(packaged_task&& __other) noexcept
+ {
+ packaged_task(std::move(__other)).swap(*this);
+ return *this;
+ }
+
+ void
+ swap(packaged_task& __other) noexcept
+ { _M_state.swap(__other._M_state); }
+
+ bool
+ valid() const noexcept
+ { return static_cast<bool>(_M_state); }
+
+ // Result retrieval
+ future<_Res>
+ get_future()
+ { return future<_Res>(_M_state); }
+
+ // Execution
+ void
+ operator()(_ArgTypes... __args)
+ {
+ __future_base::_State_base::_S_check(_M_state);
+ _M_state->_M_run(std::forward<_ArgTypes>(__args)...);
+ }
+
+ void
+ reset()
+ {
+ __future_base::_State_base::_S_check(_M_state);
+ packaged_task __tmp;
+ __tmp._M_state = _M_state;
+ _M_state = _M_state->_M_reset();
+ }
+ };
+
+ /// swap
+ template<typename _Res, typename... _ArgTypes>
+ inline void
+ swap(packaged_task<_Res(_ArgTypes...)>& __x,
+ packaged_task<_Res(_ArgTypes...)>& __y) noexcept
+ { __x.swap(__y); }
+
+ template<typename _Res, typename _Alloc>
+ struct uses_allocator<packaged_task<_Res>, _Alloc>
+ : public true_type { };
+
+
+ template<typename _BoundFn, typename _Res>
+ class __future_base::_Deferred_state final
+ : public __future_base::_State_base
+ {
+ public:
+ explicit
+ _Deferred_state(_BoundFn&& __fn)
+ : _M_result(new _Result<_Res>()), _M_fn(std::move(__fn))
+ { }
+
+ private:
+ typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
+ _Ptr_type _M_result;
+ _BoundFn _M_fn;
+
+ // Run the deferred function.
+ virtual void
+ _M_complete_async()
+ {
+ // safe to call multiple times so ignore failure
+ _M_set_result(_S_task_setter(_M_result, _M_fn), true);
+ }
+
+ virtual bool
+ _M_has_deferred() const { return static_cast<bool>(_M_result); }
+ };
+
+ class __future_base::_Async_state_commonV2
+ : public __future_base::_State_base
+ {
+ protected:
+ ~_Async_state_commonV2() = default;
+
+ // Make waiting functions block until the thread completes, as if joined.
+ virtual void _M_complete_async() { _M_join(); }
+
+ void _M_join() { std::call_once(_M_once, &thread::join, ref(_M_thread)); }
+
+ thread _M_thread;
+ once_flag _M_once;
+ };
+
+ template<typename _BoundFn, typename _Res>
+ class __future_base::_Async_state_impl final
+ : public __future_base::_Async_state_commonV2
+ {
+ public:
+ explicit
+ _Async_state_impl(_BoundFn&& __fn)
+ : _M_result(new _Result<_Res>()), _M_fn(std::move(__fn))
+ {
+ _M_thread = std::thread{ [this] {
+ _M_set_result(_S_task_setter(_M_result, _M_fn));
+ } };
+ }
+
+ ~_Async_state_impl() { _M_join(); }
+
+ private:
+ typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type;
+ _Ptr_type _M_result;
+ _BoundFn _M_fn;
+ };
+
+ template<typename _BoundFn>
+ inline std::shared_ptr<__future_base::_State_base>
+ __future_base::_S_make_deferred_state(_BoundFn&& __fn)
+ {
+ typedef typename remove_reference<_BoundFn>::type __fn_type;
+ typedef _Deferred_state<__fn_type> __state_type;
+ return std::make_shared<__state_type>(std::move(__fn));
+ }
+
+ template<typename _BoundFn>
+ inline std::shared_ptr<__future_base::_State_base>
+ __future_base::_S_make_async_state(_BoundFn&& __fn)
+ {
+ typedef typename remove_reference<_BoundFn>::type __fn_type;
+ typedef _Async_state_impl<__fn_type> __state_type;
+ return std::make_shared<__state_type>(std::move(__fn));
+ }
+
+
+ /// async
+ template<typename _Fn, typename... _Args>
+ future<typename result_of<_Fn(_Args...)>::type>
+ async(launch __policy, _Fn&& __fn, _Args&&... __args)
+ {
+ typedef typename result_of<_Fn(_Args...)>::type result_type;
+ std::shared_ptr<__future_base::_State_base> __state;
+ if ((__policy & (launch::async|launch::deferred)) == launch::async)
+ {
+ __state = __future_base::_S_make_async_state(std::__bind_simple(
+ std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
+ }
+ else
+ {
+ __state = __future_base::_S_make_deferred_state(std::__bind_simple(
+ std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
+ }
+ return future<result_type>(__state);
+ }
+
+ /// async, potential overload
+ template<typename _Fn, typename... _Args>
+ inline future<typename result_of<_Fn(_Args...)>::type>
+ async(_Fn&& __fn, _Args&&... __args)
+ {
+ return async(launch::async|launch::deferred, std::forward<_Fn>(__fn),
+ std::forward<_Args>(__args)...);
+ }
+
+#endif // _GLIBCXX_ASYNC_ABI_COMPAT
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
+ // && ATOMIC_INT_LOCK_FREE
+
+ // @} group futures
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif // C++11
+
+#endif // _GLIBCXX_FUTURE
diff --git a/gcc-4.9/libstdc++-v3/include/std/iomanip b/gcc-4.9/libstdc++-v3/include/std/iomanip
new file mode 100644
index 0000000..b2c7b95
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/iomanip
@@ -0,0 +1,531 @@
+// Standard stream manipulators -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/iomanip
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 27.6.3 Standard manipulators
+//
+
+#ifndef _GLIBCXX_IOMANIP
+#define _GLIBCXX_IOMANIP 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <iosfwd>
+#include <bits/ios_base.h>
+
+#if __cplusplus >= 201103L
+#include <locale>
+#endif
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // [27.6.3] standard manipulators
+ // Also see DR 183.
+
+ struct _Resetiosflags { ios_base::fmtflags _M_mask; };
+
+ /**
+ * @brief Manipulator for @c setf.
+ * @param __mask A format flags mask.
+ *
+ * Sent to a stream object, this manipulator resets the specified flags,
+ * via @e stream.setf(0,__mask).
+ */
+ inline _Resetiosflags
+ resetiosflags(ios_base::fmtflags __mask)
+ { return { __mask }; }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f)
+ {
+ __is.setf(ios_base::fmtflags(0), __f._M_mask);
+ return __is;
+ }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, _Resetiosflags __f)
+ {
+ __os.setf(ios_base::fmtflags(0), __f._M_mask);
+ return __os;
+ }
+
+
+ struct _Setiosflags { ios_base::fmtflags _M_mask; };
+
+ /**
+ * @brief Manipulator for @c setf.
+ * @param __mask A format flags mask.
+ *
+ * Sent to a stream object, this manipulator sets the format flags
+ * to @a __mask.
+ */
+ inline _Setiosflags
+ setiosflags(ios_base::fmtflags __mask)
+ { return { __mask }; }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f)
+ {
+ __is.setf(__f._M_mask);
+ return __is;
+ }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, _Setiosflags __f)
+ {
+ __os.setf(__f._M_mask);
+ return __os;
+ }
+
+
+ struct _Setbase { int _M_base; };
+
+ /**
+ * @brief Manipulator for @c setf.
+ * @param __base A numeric base.
+ *
+ * Sent to a stream object, this manipulator changes the
+ * @c ios_base::basefield flags to @c oct, @c dec, or @c hex when @a base
+ * is 8, 10, or 16, accordingly, and to 0 if @a __base is any other value.
+ */
+ inline _Setbase
+ setbase(int __base)
+ { return { __base }; }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f)
+ {
+ __is.setf(__f._M_base == 8 ? ios_base::oct :
+ __f._M_base == 10 ? ios_base::dec :
+ __f._M_base == 16 ? ios_base::hex :
+ ios_base::fmtflags(0), ios_base::basefield);
+ return __is;
+ }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, _Setbase __f)
+ {
+ __os.setf(__f._M_base == 8 ? ios_base::oct :
+ __f._M_base == 10 ? ios_base::dec :
+ __f._M_base == 16 ? ios_base::hex :
+ ios_base::fmtflags(0), ios_base::basefield);
+ return __os;
+ }
+
+
+ template<typename _CharT>
+ struct _Setfill { _CharT _M_c; };
+
+ /**
+ * @brief Manipulator for @c fill.
+ * @param __c The new fill character.
+ *
+ * Sent to a stream object, this manipulator calls @c fill(__c) for that
+ * object.
+ */
+ template<typename _CharT>
+ inline _Setfill<_CharT>
+ setfill(_CharT __c)
+ { return { __c }; }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f)
+ {
+ __is.fill(__f._M_c);
+ return __is;
+ }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, _Setfill<_CharT> __f)
+ {
+ __os.fill(__f._M_c);
+ return __os;
+ }
+
+
+ struct _Setprecision { int _M_n; };
+
+ /**
+ * @brief Manipulator for @c precision.
+ * @param __n The new precision.
+ *
+ * Sent to a stream object, this manipulator calls @c precision(__n) for
+ * that object.
+ */
+ inline _Setprecision
+ setprecision(int __n)
+ { return { __n }; }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f)
+ {
+ __is.precision(__f._M_n);
+ return __is;
+ }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, _Setprecision __f)
+ {
+ __os.precision(__f._M_n);
+ return __os;
+ }
+
+
+ struct _Setw { int _M_n; };
+
+ /**
+ * @brief Manipulator for @c width.
+ * @param __n The new width.
+ *
+ * Sent to a stream object, this manipulator calls @c width(__n) for
+ * that object.
+ */
+ inline _Setw
+ setw(int __n)
+ { return { __n }; }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f)
+ {
+ __is.width(__f._M_n);
+ return __is;
+ }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, _Setw __f)
+ {
+ __os.width(__f._M_n);
+ return __os;
+ }
+
+#if __cplusplus >= 201103L
+
+ template<typename _MoneyT>
+ struct _Get_money { _MoneyT& _M_mon; bool _M_intl; };
+
+ /**
+ * @brief Extended manipulator for extracting money.
+ * @param __mon Either long double or a specialization of @c basic_string.
+ * @param __intl A bool indicating whether international format
+ * is to be used.
+ *
+ * Sent to a stream object, this manipulator extracts @a __mon.
+ */
+ template<typename _MoneyT>
+ inline _Get_money<_MoneyT>
+ get_money(_MoneyT& __mon, bool __intl = false)
+ { return { __mon, __intl }; }
+
+ template<typename _CharT, typename _Traits, typename _MoneyT>
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is, _Get_money<_MoneyT> __f)
+ {
+ typename basic_istream<_CharT, _Traits>::sentry __cerb(__is, false);
+ if (__cerb)
+ {
+ ios_base::iostate __err = ios_base::goodbit;
+ __try
+ {
+ typedef istreambuf_iterator<_CharT, _Traits> _Iter;
+ typedef money_get<_CharT, _Iter> _MoneyGet;
+
+ const _MoneyGet& __mg = use_facet<_MoneyGet>(__is.getloc());
+ __mg.get(_Iter(__is.rdbuf()), _Iter(), __f._M_intl,
+ __is, __err, __f._M_mon);
+ }
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ __is._M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
+ { __is._M_setstate(ios_base::badbit); }
+ if (__err)
+ __is.setstate(__err);
+ }
+ return __is;
+ }
+
+
+ template<typename _MoneyT>
+ struct _Put_money { const _MoneyT& _M_mon; bool _M_intl; };
+
+ /**
+ * @brief Extended manipulator for inserting money.
+ * @param __mon Either long double or a specialization of @c basic_string.
+ * @param __intl A bool indicating whether international format
+ * is to be used.
+ *
+ * Sent to a stream object, this manipulator inserts @a __mon.
+ */
+ template<typename _MoneyT>
+ inline _Put_money<_MoneyT>
+ put_money(const _MoneyT& __mon, bool __intl = false)
+ { return { __mon, __intl }; }
+
+ template<typename _CharT, typename _Traits, typename _MoneyT>
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, _Put_money<_MoneyT> __f)
+ {
+ typename basic_ostream<_CharT, _Traits>::sentry __cerb(__os);
+ if (__cerb)
+ {
+ ios_base::iostate __err = ios_base::goodbit;
+ __try
+ {
+ typedef ostreambuf_iterator<_CharT, _Traits> _Iter;
+ typedef money_put<_CharT, _Iter> _MoneyPut;
+
+ const _MoneyPut& __mp = use_facet<_MoneyPut>(__os.getloc());
+ if (__mp.put(_Iter(__os.rdbuf()), __f._M_intl, __os,
+ __os.fill(), __f._M_mon).failed())
+ __err |= ios_base::badbit;
+ }
+ __catch(__cxxabiv1::__forced_unwind&)
+ {
+ __os._M_setstate(ios_base::badbit);
+ __throw_exception_again;
+ }
+ __catch(...)
+ { __os._M_setstate(ios_base::badbit); }
+ if (__err)
+ __os.setstate(__err);
+ }
+ return __os;
+ }
+
+#if __cplusplus > 201103L
+
+_GLIBCXX_END_NAMESPACE_VERSION
+ namespace __detail {
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @brief Struct for delimited strings.
+ * The left and right delimiters can be different.
+ */
+ template<typename _String, typename _CharT>
+ struct _Quoted_string
+ {
+ static_assert(is_reference<_String>::value
+ || is_pointer<_String>::value,
+ "String type must be pointer or reference");
+
+ _Quoted_string(_String __str, _CharT __del, _CharT __esc)
+ : _M_string(__str), _M_delim{__del}, _M_escape{__esc}
+ { }
+
+ _Quoted_string&
+ operator=(_Quoted_string&) = delete;
+
+ _String _M_string;
+ _CharT _M_delim;
+ _CharT _M_escape;
+ };
+
+ /**
+ * @brief Inserter for delimited strings.
+ * The left and right delimiters can be different.
+ */
+ template<typename _CharT, typename _Traits>
+ auto&
+ operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+ const _Quoted_string<const _CharT*, _CharT>& __str)
+ {
+ __os << __str._M_delim;
+ for (const _CharT* __c = __str._M_string; *__c; ++__c)
+ {
+ if (*__c == __str._M_delim || *__c == __str._M_escape)
+ __os << __str._M_escape;
+ __os << *__c;
+ }
+ __os << __str._M_delim;
+
+ return __os;
+ }
+
+ /**
+ * @brief Inserter for delimited strings.
+ * The left and right delimiters can be different.
+ */
+ template<typename _CharT, typename _Traits, typename _String>
+ auto&
+ operator<<(std::basic_ostream<_CharT, _Traits>& __os,
+ const _Quoted_string<_String, _CharT>& __str)
+ {
+ __os << __str._M_delim;
+ for (auto& __c : __str._M_string)
+ {
+ if (__c == __str._M_delim || __c == __str._M_escape)
+ __os << __str._M_escape;
+ __os << __c;
+ }
+ __os << __str._M_delim;
+
+ return __os;
+ }
+
+ /**
+ * @brief Extractor for delimited strings.
+ * The left and right delimiters can be different.
+ */
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ auto&
+ operator>>(std::basic_istream<_CharT, _Traits>& __is,
+ const _Quoted_string<basic_string<_CharT, _Traits, _Alloc>&,
+ _CharT>& __str)
+ {
+ __str._M_string.clear();
+
+ _CharT __c;
+ __is >> __c;
+ if (!__is.good())
+ return __is;
+ if (__c != __str._M_delim)
+ {
+ __is.unget();
+ __is >> __str._M_string;
+ return __is;
+ }
+ std::ios_base::fmtflags __flags
+ = __is.flags(__is.flags() & ~std::ios_base::skipws);
+ do
+ {
+ __is >> __c;
+ if (!__is.good())
+ break;
+ if (__c == __str._M_escape)
+ {
+ __is >> __c;
+ if (!__is.good())
+ break;
+ }
+ else if (__c == __str._M_delim)
+ break;
+ __str._M_string += __c;
+ }
+ while (true);
+ __is.setf(__flags);
+
+ return __is;
+ }
+ _GLIBCXX_END_NAMESPACE_VERSION
+ } // namespace __detail
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @brief Manipulator for quoted strings.
+ * @param __str String to quote.
+ * @param __delim Character to quote string with.
+ * @param __escape Escape character to escape itself or quote character.
+ */
+ template<typename _CharT>
+ inline auto
+ quoted(const _CharT* __string,
+ _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
+ {
+ return __detail::_Quoted_string<const _CharT*, _CharT>(__string, __delim,
+ __escape);
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ inline auto
+ quoted(const basic_string<_CharT, _Traits, _Alloc>& __string,
+ _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
+ {
+ return __detail::_Quoted_string<
+ const basic_string<_CharT, _Traits, _Alloc>&, _CharT>(
+ __string, __delim, __escape);
+ }
+
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ inline auto
+ quoted(basic_string<_CharT, _Traits, _Alloc>& __string,
+ _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\'))
+ {
+ return __detail::_Quoted_string<
+ basic_string<_CharT, _Traits, _Alloc>&, _CharT>(
+ __string, __delim, __escape);
+ }
+
+#endif // __cplusplus > 201103L
+
+#endif // __cplusplus >= 201103L
+
+ // Inhibit implicit instantiations for required instantiations,
+ // which are defined via explicit instantiations elsewhere.
+ // NB: This syntax is a GNU extension.
+#if _GLIBCXX_EXTERN_TEMPLATE
+ extern template ostream& operator<<(ostream&, _Setfill<char>);
+ extern template ostream& operator<<(ostream&, _Setiosflags);
+ extern template ostream& operator<<(ostream&, _Resetiosflags);
+ extern template ostream& operator<<(ostream&, _Setbase);
+ extern template ostream& operator<<(ostream&, _Setprecision);
+ extern template ostream& operator<<(ostream&, _Setw);
+ extern template istream& operator>>(istream&, _Setfill<char>);
+ extern template istream& operator>>(istream&, _Setiosflags);
+ extern template istream& operator>>(istream&, _Resetiosflags);
+ extern template istream& operator>>(istream&, _Setbase);
+ extern template istream& operator>>(istream&, _Setprecision);
+ extern template istream& operator>>(istream&, _Setw);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ extern template wostream& operator<<(wostream&, _Setfill<wchar_t>);
+ extern template wostream& operator<<(wostream&, _Setiosflags);
+ extern template wostream& operator<<(wostream&, _Resetiosflags);
+ extern template wostream& operator<<(wostream&, _Setbase);
+ extern template wostream& operator<<(wostream&, _Setprecision);
+ extern template wostream& operator<<(wostream&, _Setw);
+ extern template wistream& operator>>(wistream&, _Setfill<wchar_t>);
+ extern template wistream& operator>>(wistream&, _Setiosflags);
+ extern template wistream& operator>>(wistream&, _Resetiosflags);
+ extern template wistream& operator>>(wistream&, _Setbase);
+ extern template wistream& operator>>(wistream&, _Setprecision);
+ extern template wistream& operator>>(wistream&, _Setw);
+#endif
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif /* _GLIBCXX_IOMANIP */
diff --git a/gcc-4.9/libstdc++-v3/include/std/ios b/gcc-4.9/libstdc++-v3/include/std/ios
new file mode 100644
index 0000000..5d69c4b
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/ios
@@ -0,0 +1,46 @@
+// Iostreams base classes -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/ios
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 27.4 Iostreams base classes
+//
+
+#ifndef _GLIBCXX_IOS
+#define _GLIBCXX_IOS 1
+
+#pragma GCC system_header
+
+#include <iosfwd>
+#include <exception> // For ios_base::failure
+#include <bits/char_traits.h> // For char_traits, streamoff, streamsize, fpos
+#include <bits/localefwd.h> // For class locale
+#include <bits/ios_base.h> // For ios_base declarations.
+#include <streambuf>
+#include <bits/basic_ios.h>
+
+#endif /* _GLIBCXX_IOS */
diff --git a/gcc-4.9/libstdc++-v3/include/std/iosfwd b/gcc-4.9/libstdc++-v3/include/std/iosfwd
new file mode 100644
index 0000000..50dd949
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/iosfwd
@@ -0,0 +1,210 @@
+// <iosfwd> Forward declarations -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/iosfwd
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 27.2 Forward declarations
+//
+
+#ifndef _GLIBCXX_IOSFWD
+#define _GLIBCXX_IOSFWD 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <bits/stringfwd.h> // For string forward declarations.
+#include <bits/postypes.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @defgroup io I/O
+ *
+ * Nearly all of the I/O classes are parameterized on the type of
+ * characters they read and write. (The major exception is ios_base at
+ * the top of the hierarchy.) This is a change from pre-Standard
+ * streams, which were not templates.
+ *
+ * For ease of use and compatibility, all of the basic_* I/O-related
+ * classes are given typedef names for both of the builtin character
+ * widths (wide and narrow). The typedefs are the same as the
+ * pre-Standard names, for example:
+ *
+ * @code
+ * typedef basic_ifstream<char> ifstream;
+ * @endcode
+ *
+ * Because properly forward-declaring these classes can be difficult, you
+ * should not do it yourself. Instead, include the &lt;iosfwd&gt;
+ * header, which contains only declarations of all the I/O classes as
+ * well as the typedefs. Trying to forward-declare the typedefs
+ * themselves (e.g., <code>class ostream;</code>) is not valid ISO C++.
+ *
+ * For more specific declarations, see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch24.html
+ *
+ * @{
+ */
+ class ios_base;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_ios;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_streambuf;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_istream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_ostream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_iostream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+ class basic_stringbuf;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+ class basic_istringstream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+ class basic_ostringstream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+ class basic_stringstream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_filebuf;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_ifstream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_ofstream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class basic_fstream;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class istreambuf_iterator;
+
+ template<typename _CharT, typename _Traits = char_traits<_CharT> >
+ class ostreambuf_iterator;
+
+
+ /// Base class for @c char streams.
+ typedef basic_ios<char> ios;
+
+ /// Base class for @c char buffers.
+ typedef basic_streambuf<char> streambuf;
+
+ /// Base class for @c char input streams.
+ typedef basic_istream<char> istream;
+
+ /// Base class for @c char output streams.
+ typedef basic_ostream<char> ostream;
+
+ /// Base class for @c char mixed input and output streams.
+ typedef basic_iostream<char> iostream;
+
+ /// Class for @c char memory buffers.
+ typedef basic_stringbuf<char> stringbuf;
+
+ /// Class for @c char input memory streams.
+ typedef basic_istringstream<char> istringstream;
+
+ /// Class for @c char output memory streams.
+ typedef basic_ostringstream<char> ostringstream;
+
+ /// Class for @c char mixed input and output memory streams.
+ typedef basic_stringstream<char> stringstream;
+
+ /// Class for @c char file buffers.
+ typedef basic_filebuf<char> filebuf;
+
+ /// Class for @c char input file streams.
+ typedef basic_ifstream<char> ifstream;
+
+ /// Class for @c char output file streams.
+ typedef basic_ofstream<char> ofstream;
+
+ /// Class for @c char mixed input and output file streams.
+ typedef basic_fstream<char> fstream;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ /// Base class for @c wchar_t streams.
+ typedef basic_ios<wchar_t> wios;
+
+ /// Base class for @c wchar_t buffers.
+ typedef basic_streambuf<wchar_t> wstreambuf;
+
+ /// Base class for @c wchar_t input streams.
+ typedef basic_istream<wchar_t> wistream;
+
+ /// Base class for @c wchar_t output streams.
+ typedef basic_ostream<wchar_t> wostream;
+
+ /// Base class for @c wchar_t mixed input and output streams.
+ typedef basic_iostream<wchar_t> wiostream;
+
+ /// Class for @c wchar_t memory buffers.
+ typedef basic_stringbuf<wchar_t> wstringbuf;
+
+ /// Class for @c wchar_t input memory streams.
+ typedef basic_istringstream<wchar_t> wistringstream;
+
+ /// Class for @c wchar_t output memory streams.
+ typedef basic_ostringstream<wchar_t> wostringstream;
+
+ /// Class for @c wchar_t mixed input and output memory streams.
+ typedef basic_stringstream<wchar_t> wstringstream;
+
+ /// Class for @c wchar_t file buffers.
+ typedef basic_filebuf<wchar_t> wfilebuf;
+
+ /// Class for @c wchar_t input file streams.
+ typedef basic_ifstream<wchar_t> wifstream;
+
+ /// Class for @c wchar_t output file streams.
+ typedef basic_ofstream<wchar_t> wofstream;
+
+ /// Class for @c wchar_t mixed input and output file streams.
+ typedef basic_fstream<wchar_t> wfstream;
+#endif
+ /** @} */
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif /* _GLIBCXX_IOSFWD */
diff --git a/gcc-4.9/libstdc++-v3/include/std/iostream b/gcc-4.9/libstdc++-v3/include/std/iostream
new file mode 100644
index 0000000..85d2b95
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/iostream
@@ -0,0 +1,79 @@
+// Standard iostream objects -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/iostream
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 27.3 Standard iostream objects
+//
+
+#ifndef _GLIBCXX_IOSTREAM
+#define _GLIBCXX_IOSTREAM 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <ostream>
+#include <istream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @name Standard Stream Objects
+ *
+ * The &lt;iostream&gt; header declares the eight <em>standard stream
+ * objects</em>. For other declarations, see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch24.html
+ * and the @link iosfwd I/O forward declarations @endlink
+ *
+ * They are required by default to cooperate with the global C
+ * library's @c FILE streams, and to be available during program
+ * startup and termination. For more information, see the HOWTO
+ * linked to above.
+ */
+ //@{
+ extern istream cin; /// Linked to standard input
+ extern ostream cout; /// Linked to standard output
+ extern ostream cerr; /// Linked to standard error (unbuffered)
+ extern ostream clog; /// Linked to standard error (buffered)
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ extern wistream wcin; /// Linked to standard input
+ extern wostream wcout; /// Linked to standard output
+ extern wostream wcerr; /// Linked to standard error (unbuffered)
+ extern wostream wclog; /// Linked to standard error (buffered)
+#endif
+ //@}
+
+ // For construction of filebuffers for cout, cin, cerr, clog et. al.
+ static ios_base::Init __ioinit;
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif /* _GLIBCXX_IOSTREAM */
diff --git a/gcc-4.9/libstdc++-v3/include/std/istream b/gcc-4.9/libstdc++-v3/include/std/istream
new file mode 100644
index 0000000..f063768
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/istream
@@ -0,0 +1,881 @@
+// Input streams -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/>.
+
+//
+// ISO C++ 14882: 27.6.1 Input streams
+//
+
+/** @file include/istream
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_ISTREAM
+#define _GLIBCXX_ISTREAM 1
+
+#pragma GCC system_header
+
+#include <ios>
+#include <ostream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @brief Template class basic_istream.
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ *
+ * This is the base class for all input streams. It provides text
+ * formatting of all builtin types, and communicates with any class
+ * derived from basic_streambuf to do the actual input.
+ */
+ template<typename _CharT, typename _Traits>
+ class basic_istream : virtual public basic_ios<_CharT, _Traits>
+ {
+ public:
+ // Types (inherited from basic_ios (27.4.4)):
+ typedef _CharT char_type;
+ typedef typename _Traits::int_type int_type;
+ typedef typename _Traits::pos_type pos_type;
+ typedef typename _Traits::off_type off_type;
+ typedef _Traits traits_type;
+
+ // Non-standard Types:
+ typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
+ typedef basic_ios<_CharT, _Traits> __ios_type;
+ typedef basic_istream<_CharT, _Traits> __istream_type;
+ typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
+ __num_get_type;
+ typedef ctype<_CharT> __ctype_type;
+
+ protected:
+ // Data Members:
+ /**
+ * The number of characters extracted in the previous unformatted
+ * function; see gcount().
+ */
+ streamsize _M_gcount;
+
+ public:
+ /**
+ * @brief Base constructor.
+ *
+ * This ctor is almost never called by the user directly, rather from
+ * derived classes' initialization lists, which pass a pointer to
+ * their own stream buffer.
+ */
+ explicit
+ basic_istream(__streambuf_type* __sb)
+ : _M_gcount(streamsize(0))
+ { this->init(__sb); }
+
+ /**
+ * @brief Base destructor.
+ *
+ * This does very little apart from providing a virtual base dtor.
+ */
+ virtual
+ ~basic_istream()
+ { _M_gcount = streamsize(0); }
+
+ /// Safe prefix/suffix operations.
+ class sentry;
+ friend class sentry;
+
+ //@{
+ /**
+ * @brief Interface for manipulators.
+ *
+ * Manipulators such as @c std::ws and @c std::dec use these
+ * functions in constructs like
+ * <code>std::cin >> std::ws</code>.
+ * For more information, see the iomanip header.
+ */
+ __istream_type&
+ operator>>(__istream_type& (*__pf)(__istream_type&))
+ { return __pf(*this); }
+
+ __istream_type&
+ operator>>(__ios_type& (*__pf)(__ios_type&))
+ {
+ __pf(*this);
+ return *this;
+ }
+
+ __istream_type&
+ operator>>(ios_base& (*__pf)(ios_base&))
+ {
+ __pf(*this);
+ return *this;
+ }
+ //@}
+
+ //@{
+ /**
+ * @name Extractors
+ *
+ * All the @c operator>> functions (aka <em>formatted input
+ * functions</em>) have some common behavior. Each starts by
+ * constructing a temporary object of type std::basic_istream::sentry
+ * with the second argument (noskipws) set to false. This has several
+ * effects, concluding with the setting of a status flag; see the
+ * sentry documentation for more.
+ *
+ * If the sentry status is good, the function tries to extract
+ * whatever data is appropriate for the type of the argument.
+ *
+ * If an exception is thrown during extraction, ios_base::badbit
+ * will be turned on in the stream's error state without causing an
+ * ios_base::failure to be thrown. The original exception will then
+ * be rethrown.
+ */
+
+ //@{
+ /**
+ * @brief Integer arithmetic extractors
+ * @param __n A variable of builtin integral type.
+ * @return @c *this if successful
+ *
+ * These functions use the stream's current locale (specifically, the
+ * @c num_get facet) to parse the input data.
+ */
+ __istream_type&
+ operator>>(bool& __n)
+ { return _M_extract(__n); }
+
+ __istream_type&
+ operator>>(short& __n);
+
+ __istream_type&
+ operator>>(unsigned short& __n)
+ { return _M_extract(__n); }
+
+ __istream_type&
+ operator>>(int& __n);
+
+ __istream_type&
+ operator>>(unsigned int& __n)
+ { return _M_extract(__n); }
+
+ __istream_type&
+ operator>>(long& __n)
+ { return _M_extract(__n); }
+
+ __istream_type&
+ operator>>(unsigned long& __n)
+ { return _M_extract(__n); }
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ __istream_type&
+ operator>>(long long& __n)
+ { return _M_extract(__n); }
+
+ __istream_type&
+ operator>>(unsigned long long& __n)
+ { return _M_extract(__n); }
+#endif
+ //@}
+
+ //@{
+ /**
+ * @brief Floating point arithmetic extractors
+ * @param __f A variable of builtin floating point type.
+ * @return @c *this if successful
+ *
+ * These functions use the stream's current locale (specifically, the
+ * @c num_get facet) to parse the input data.
+ */
+ __istream_type&
+ operator>>(float& __f)
+ { return _M_extract(__f); }
+
+ __istream_type&
+ operator>>(double& __f)
+ { return _M_extract(__f); }
+
+ __istream_type&
+ operator>>(long double& __f)
+ { return _M_extract(__f); }
+ //@}
+
+ /**
+ * @brief Basic arithmetic extractors
+ * @param __p A variable of pointer type.
+ * @return @c *this if successful
+ *
+ * These functions use the stream's current locale (specifically, the
+ * @c num_get facet) to parse the input data.
+ */
+ __istream_type&
+ operator>>(void*& __p)
+ { return _M_extract(__p); }
+
+ /**
+ * @brief Extracting into another streambuf.
+ * @param __sb A pointer to a streambuf
+ *
+ * This function behaves like one of the basic arithmetic extractors,
+ * in that it also constructs a sentry object and has the same error
+ * handling behavior.
+ *
+ * If @p __sb is NULL, the stream will set failbit in its error state.
+ *
+ * Characters are extracted from this stream and inserted into the
+ * @p __sb streambuf until one of the following occurs:
+ *
+ * - the input stream reaches end-of-file,
+ * - insertion into the output buffer fails (in this case, the
+ * character that would have been inserted is not extracted), or
+ * - an exception occurs (and in this case is caught)
+ *
+ * If the function inserts no characters, failbit is set.
+ */
+ __istream_type&
+ operator>>(__streambuf_type* __sb);
+ //@}
+
+ // [27.6.1.3] unformatted input
+ /**
+ * @brief Character counting
+ * @return The number of characters extracted by the previous
+ * unformatted input function dispatched for this stream.
+ */
+ streamsize
+ gcount() const
+ { return _M_gcount; }
+
+ //@{
+ /**
+ * @name Unformatted Input Functions
+ *
+ * All the unformatted input functions have some common behavior.
+ * Each starts by constructing a temporary object of type
+ * std::basic_istream::sentry with the second argument (noskipws)
+ * set to true. This has several effects, concluding with the
+ * setting of a status flag; see the sentry documentation for more.
+ *
+ * If the sentry status is good, the function tries to extract
+ * whatever data is appropriate for the type of the argument.
+ *
+ * The number of characters extracted is stored for later retrieval
+ * by gcount().
+ *
+ * If an exception is thrown during extraction, ios_base::badbit
+ * will be turned on in the stream's error state without causing an
+ * ios_base::failure to be thrown. The original exception will then
+ * be rethrown.
+ */
+
+ /**
+ * @brief Simple extraction.
+ * @return A character, or eof().
+ *
+ * Tries to extract a character. If none are available, sets failbit
+ * and returns traits::eof().
+ */
+ int_type
+ get();
+
+ /**
+ * @brief Simple extraction.
+ * @param __c The character in which to store data.
+ * @return *this
+ *
+ * Tries to extract a character and store it in @a __c. If none are
+ * available, sets failbit and returns traits::eof().
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
+ __istream_type&
+ get(char_type& __c);
+
+ /**
+ * @brief Simple multiple-character extraction.
+ * @param __s Pointer to an array.
+ * @param __n Maximum number of characters to store in @a __s.
+ * @param __delim A "stop" character.
+ * @return *this
+ *
+ * Characters are extracted and stored into @a __s until one of the
+ * following happens:
+ *
+ * - @c __n-1 characters are stored
+ * - the input sequence reaches EOF
+ * - the next character equals @a __delim, in which case the character
+ * is not extracted
+ *
+ * If no characters are stored, failbit is set in the stream's error
+ * state.
+ *
+ * In any case, a null character is stored into the next location in
+ * the array.
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
+ __istream_type&
+ get(char_type* __s, streamsize __n, char_type __delim);
+
+ /**
+ * @brief Simple multiple-character extraction.
+ * @param __s Pointer to an array.
+ * @param __n Maximum number of characters to store in @a s.
+ * @return *this
+ *
+ * Returns @c get(__s,__n,widen(&apos;\\n&apos;)).
+ */
+ __istream_type&
+ get(char_type* __s, streamsize __n)
+ { return this->get(__s, __n, this->widen('\n')); }
+
+ /**
+ * @brief Extraction into another streambuf.
+ * @param __sb A streambuf in which to store data.
+ * @param __delim A "stop" character.
+ * @return *this
+ *
+ * Characters are extracted and inserted into @a __sb until one of the
+ * following happens:
+ *
+ * - the input sequence reaches EOF
+ * - insertion into the output buffer fails (in this case, the
+ * character that would have been inserted is not extracted)
+ * - the next character equals @a __delim (in this case, the character
+ * is not extracted)
+ * - an exception occurs (and in this case is caught)
+ *
+ * If no characters are stored, failbit is set in the stream's error
+ * state.
+ */
+ __istream_type&
+ get(__streambuf_type& __sb, char_type __delim);
+
+ /**
+ * @brief Extraction into another streambuf.
+ * @param __sb A streambuf in which to store data.
+ * @return *this
+ *
+ * Returns @c get(__sb,widen(&apos;\\n&apos;)).
+ */
+ __istream_type&
+ get(__streambuf_type& __sb)
+ { return this->get(__sb, this->widen('\n')); }
+
+ /**
+ * @brief String extraction.
+ * @param __s A character array in which to store the data.
+ * @param __n Maximum number of characters to extract.
+ * @param __delim A "stop" character.
+ * @return *this
+ *
+ * Extracts and stores characters into @a __s until one of the
+ * following happens. Note that these criteria are required to be
+ * tested in the order listed here, to allow an input line to exactly
+ * fill the @a __s array without setting failbit.
+ *
+ * -# the input sequence reaches end-of-file, in which case eofbit
+ * is set in the stream error state
+ * -# the next character equals @c __delim, in which case the character
+ * is extracted (and therefore counted in @c gcount()) but not stored
+ * -# @c __n-1 characters are stored, in which case failbit is set
+ * in the stream error state
+ *
+ * If no characters are extracted, failbit is set. (An empty line of
+ * input should therefore not cause failbit to be set.)
+ *
+ * In any case, a null character is stored in the next location in
+ * the array.
+ */
+ __istream_type&
+ getline(char_type* __s, streamsize __n, char_type __delim);
+
+ /**
+ * @brief String extraction.
+ * @param __s A character array in which to store the data.
+ * @param __n Maximum number of characters to extract.
+ * @return *this
+ *
+ * Returns @c getline(__s,__n,widen(&apos;\\n&apos;)).
+ */
+ __istream_type&
+ getline(char_type* __s, streamsize __n)
+ { return this->getline(__s, __n, this->widen('\n')); }
+
+ /**
+ * @brief Discarding characters
+ * @param __n Number of characters to discard.
+ * @param __delim A "stop" character.
+ * @return *this
+ *
+ * Extracts characters and throws them away until one of the
+ * following happens:
+ * - if @a __n @c != @c std::numeric_limits<int>::max(), @a __n
+ * characters are extracted
+ * - the input sequence reaches end-of-file
+ * - the next character equals @a __delim (in this case, the character
+ * is extracted); note that this condition will never occur if
+ * @a __delim equals @c traits::eof().
+ *
+ * NB: Provide three overloads, instead of the single function
+ * (with defaults) mandated by the Standard: this leads to a
+ * better performing implementation, while still conforming to
+ * the Standard.
+ */
+ __istream_type&
+ ignore(streamsize __n, int_type __delim);
+
+ __istream_type&
+ ignore(streamsize __n);
+
+ __istream_type&
+ ignore();
+
+ /**
+ * @brief Looking ahead in the stream
+ * @return The next character, or eof().
+ *
+ * If, after constructing the sentry object, @c good() is false,
+ * returns @c traits::eof(). Otherwise reads but does not extract
+ * the next input character.
+ */
+ int_type
+ peek();
+
+ /**
+ * @brief Extraction without delimiters.
+ * @param __s A character array.
+ * @param __n Maximum number of characters to store.
+ * @return *this
+ *
+ * If the stream state is @c good(), extracts characters and stores
+ * them into @a __s until one of the following happens:
+ * - @a __n characters are stored
+ * - the input sequence reaches end-of-file, in which case the error
+ * state is set to @c failbit|eofbit.
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
+ __istream_type&
+ read(char_type* __s, streamsize __n);
+
+ /**
+ * @brief Extraction until the buffer is exhausted, but no more.
+ * @param __s A character array.
+ * @param __n Maximum number of characters to store.
+ * @return The number of characters extracted.
+ *
+ * Extracts characters and stores them into @a __s depending on the
+ * number of characters remaining in the streambuf's buffer,
+ * @c rdbuf()->in_avail(), called @c A here:
+ * - if @c A @c == @c -1, sets eofbit and extracts no characters
+ * - if @c A @c == @c 0, extracts no characters
+ * - if @c A @c > @c 0, extracts @c min(A,n)
+ *
+ * The goal is to empty the current buffer, and to not request any
+ * more from the external input sequence controlled by the streambuf.
+ */
+ streamsize
+ readsome(char_type* __s, streamsize __n);
+
+ /**
+ * @brief Unextracting a single character.
+ * @param __c The character to push back into the input stream.
+ * @return *this
+ *
+ * If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c).
+ *
+ * If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
+ * the error state.
+ *
+ * @note This function first clears eofbit. Since no characters
+ * are extracted, the next call to @c gcount() will return 0,
+ * as required by DR 60.
+ */
+ __istream_type&
+ putback(char_type __c);
+
+ /**
+ * @brief Unextracting the previous character.
+ * @return *this
+ *
+ * If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c).
+ *
+ * If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
+ * the error state.
+ *
+ * @note This function first clears eofbit. Since no characters
+ * are extracted, the next call to @c gcount() will return 0,
+ * as required by DR 60.
+ */
+ __istream_type&
+ unget();
+
+ /**
+ * @brief Synchronizing the stream buffer.
+ * @return 0 on success, -1 on failure
+ *
+ * If @c rdbuf() is a null pointer, returns -1.
+ *
+ * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
+ * sets badbit and returns -1.
+ *
+ * Otherwise, returns 0.
+ *
+ * @note This function does not count the number of characters
+ * extracted, if any, and therefore does not affect the next
+ * call to @c gcount().
+ */
+ int
+ sync();
+
+ /**
+ * @brief Getting the current read position.
+ * @return A file position object.
+ *
+ * If @c fail() is not false, returns @c pos_type(-1) to indicate
+ * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,in).
+ *
+ * @note This function does not count the number of characters
+ * extracted, if any, and therefore does not affect the next
+ * call to @c gcount(). At variance with putback, unget and
+ * seekg, eofbit is not cleared first.
+ */
+ pos_type
+ tellg();
+
+ /**
+ * @brief Changing the current read position.
+ * @param __pos A file position object.
+ * @return *this
+ *
+ * If @c fail() is not true, calls @c rdbuf()->pubseekpos(__pos). If
+ * that function fails, sets failbit.
+ *
+ * @note This function first clears eofbit. It does not count the
+ * number of characters extracted, if any, and therefore does
+ * not affect the next call to @c gcount().
+ */
+ __istream_type&
+ seekg(pos_type);
+
+ /**
+ * @brief Changing the current read position.
+ * @param __off A file offset object.
+ * @param __dir The direction in which to seek.
+ * @return *this
+ *
+ * If @c fail() is not true, calls @c rdbuf()->pubseekoff(__off,__dir).
+ * If that function fails, sets failbit.
+ *
+ * @note This function first clears eofbit. It does not count the
+ * number of characters extracted, if any, and therefore does
+ * not affect the next call to @c gcount().
+ */
+ __istream_type&
+ seekg(off_type, ios_base::seekdir);
+ //@}
+
+ protected:
+ basic_istream()
+ : _M_gcount(streamsize(0))
+ { this->init(0); }
+
+ template<typename _ValueT>
+ __istream_type&
+ _M_extract(_ValueT& __v);
+ };
+
+ /// Explicit specialization declarations, defined in src/istream.cc.
+ template<>
+ basic_istream<char>&
+ basic_istream<char>::
+ getline(char_type* __s, streamsize __n, char_type __delim);
+
+ template<>
+ basic_istream<char>&
+ basic_istream<char>::
+ ignore(streamsize __n);
+
+ template<>
+ basic_istream<char>&
+ basic_istream<char>::
+ ignore(streamsize __n, int_type __delim);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template<>
+ basic_istream<wchar_t>&
+ basic_istream<wchar_t>::
+ getline(char_type* __s, streamsize __n, char_type __delim);
+
+ template<>
+ basic_istream<wchar_t>&
+ basic_istream<wchar_t>::
+ ignore(streamsize __n);
+
+ template<>
+ basic_istream<wchar_t>&
+ basic_istream<wchar_t>::
+ ignore(streamsize __n, int_type __delim);
+#endif
+
+ /**
+ * @brief Performs setup work for input streams.
+ *
+ * Objects of this class are created before all of the standard
+ * extractors are run. It is responsible for <em>exception-safe
+ * prefix and suffix operations,</em> although only prefix actions
+ * are currently required by the standard.
+ */
+ template<typename _CharT, typename _Traits>
+ class basic_istream<_CharT, _Traits>::sentry
+ {
+ // Data Members.
+ bool _M_ok;
+
+ public:
+ /// Easy access to dependent types.
+ typedef _Traits traits_type;
+ typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
+ typedef basic_istream<_CharT, _Traits> __istream_type;
+ typedef typename __istream_type::__ctype_type __ctype_type;
+ typedef typename _Traits::int_type __int_type;
+
+ /**
+ * @brief The constructor performs all the work.
+ * @param __is The input stream to guard.
+ * @param __noskipws Whether to consume whitespace or not.
+ *
+ * If the stream state is good (@a __is.good() is true), then the
+ * following actions are performed, otherwise the sentry state
+ * is false (<em>not okay</em>) and failbit is set in the
+ * stream state.
+ *
+ * The sentry's preparatory actions are:
+ *
+ * -# if the stream is tied to an output stream, @c is.tie()->flush()
+ * is called to synchronize the output sequence
+ * -# if @a __noskipws is false, and @c ios_base::skipws is set in
+ * @c is.flags(), the sentry extracts and discards whitespace
+ * characters from the stream. The currently imbued locale is
+ * used to determine whether each character is whitespace.
+ *
+ * If the stream state is still good, then the sentry state becomes
+ * true (@a okay).
+ */
+ explicit
+ sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
+
+ /**
+ * @brief Quick status checking.
+ * @return The sentry state.
+ *
+ * For ease of use, sentries may be converted to booleans. The
+ * return value is that of the sentry state (true == okay).
+ */
+#if __cplusplus >= 201103L
+ explicit
+#endif
+ operator bool() const
+ { return _M_ok; }
+ };
+
+ //@{
+ /**
+ * @brief Character extractors
+ * @param __in An input stream.
+ * @param __c A character reference.
+ * @return in
+ *
+ * Behaves like one of the formatted arithmetic extractors described in
+ * std::basic_istream. After constructing a sentry object with good
+ * status, this function extracts a character (if one is available) and
+ * stores it in @a __c. Otherwise, sets failbit in the input stream.
+ */
+ template<typename _CharT, typename _Traits>
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
+
+ template<class _Traits>
+ inline basic_istream<char, _Traits>&
+ operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
+ { return (__in >> reinterpret_cast<char&>(__c)); }
+
+ template<class _Traits>
+ inline basic_istream<char, _Traits>&
+ operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
+ { return (__in >> reinterpret_cast<char&>(__c)); }
+ //@}
+
+ //@{
+ /**
+ * @brief Character string extractors
+ * @param __in An input stream.
+ * @param __s A pointer to a character array.
+ * @return __in
+ *
+ * Behaves like one of the formatted arithmetic extractors described in
+ * std::basic_istream. After constructing a sentry object with good
+ * status, this function extracts up to @c n characters and stores them
+ * into the array starting at @a __s. @c n is defined as:
+ *
+ * - if @c width() is greater than zero, @c n is width() otherwise
+ * - @c n is <em>the number of elements of the largest array of *
+ * - @c char_type that can store a terminating @c eos.</em>
+ * - [27.6.1.2.3]/6
+ *
+ * Characters are extracted and stored until one of the following happens:
+ * - @c n-1 characters are stored
+ * - EOF is reached
+ * - the next character is whitespace according to the current locale
+ * - the next character is a null byte (i.e., @c charT() )
+ *
+ * @c width(0) is then called for the input stream.
+ *
+ * If no characters are extracted, sets failbit.
+ */
+ template<typename _CharT, typename _Traits>
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
+
+ // Explicit specialization declaration, defined in src/istream.cc.
+ template<>
+ basic_istream<char>&
+ operator>>(basic_istream<char>& __in, char* __s);
+
+ template<class _Traits>
+ inline basic_istream<char, _Traits>&
+ operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
+ { return (__in >> reinterpret_cast<char*>(__s)); }
+
+ template<class _Traits>
+ inline basic_istream<char, _Traits>&
+ operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
+ { return (__in >> reinterpret_cast<char*>(__s)); }
+ //@}
+
+ /**
+ * @brief Template class basic_iostream
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ *
+ * This class multiply inherits from the input and output stream classes
+ * simply to provide a single interface.
+ */
+ template<typename _CharT, typename _Traits>
+ class basic_iostream
+ : public basic_istream<_CharT, _Traits>,
+ public basic_ostream<_CharT, _Traits>
+ {
+ public:
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 271. basic_iostream missing typedefs
+ // Types (inherited):
+ typedef _CharT char_type;
+ typedef typename _Traits::int_type int_type;
+ typedef typename _Traits::pos_type pos_type;
+ typedef typename _Traits::off_type off_type;
+ typedef _Traits traits_type;
+
+ // Non-standard Types:
+ typedef basic_istream<_CharT, _Traits> __istream_type;
+ typedef basic_ostream<_CharT, _Traits> __ostream_type;
+
+ /**
+ * @brief Constructor does nothing.
+ *
+ * Both of the parent classes are initialized with the same
+ * streambuf pointer passed to this constructor.
+ */
+ explicit
+ basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
+ : __istream_type(__sb), __ostream_type(__sb) { }
+
+ /**
+ * @brief Destructor does nothing.
+ */
+ virtual
+ ~basic_iostream() { }
+
+ protected:
+ basic_iostream()
+ : __istream_type(), __ostream_type() { }
+ };
+
+ /**
+ * @brief Quick and easy way to eat whitespace
+ *
+ * This manipulator extracts whitespace characters, stopping when the
+ * next character is non-whitespace, or when the input sequence is empty.
+ * If the sequence is empty, @c eofbit is set in the stream, but not
+ * @c failbit.
+ *
+ * The current locale is used to distinguish whitespace characters.
+ *
+ * Example:
+ * @code
+ * MyClass mc;
+ *
+ * std::cin >> std::ws >> mc;
+ * @endcode
+ * will skip leading whitespace before calling operator>> on cin and your
+ * object. Note that the same effect can be achieved by creating a
+ * std::basic_istream::sentry inside your definition of operator>>.
+ */
+ template<typename _CharT, typename _Traits>
+ basic_istream<_CharT, _Traits>&
+ ws(basic_istream<_CharT, _Traits>& __is);
+
+#if __cplusplus >= 201103L
+ // [27.7.1.6] Rvalue stream extraction
+ /**
+ * @brief Generic extractor for rvalue stream
+ * @param __is An input stream.
+ * @param __x A reference to the extraction target.
+ * @return is
+ *
+ * This is just a forwarding function to allow extraction from
+ * rvalue streams since they won't bind to the extractor functions
+ * that take an lvalue reference.
+ */
+ template<typename _CharT, typename _Traits, typename _Tp>
+ inline basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
+ { return (__is >> __x); }
+#endif // C++11
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#include <bits/istream.tcc>
+
+#endif /* _GLIBCXX_ISTREAM */
diff --git a/gcc-4.9/libstdc++-v3/include/std/iterator b/gcc-4.9/libstdc++-v3/include/std/iterator
new file mode 100644
index 0000000..f9ce095
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/iterator
@@ -0,0 +1,70 @@
+// <iterator> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/iterator
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_ITERATOR
+#define _GLIBCXX_ITERATOR 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <bits/stl_iterator_base_types.h>
+#include <bits/stl_iterator_base_funcs.h>
+#include <bits/stl_iterator.h>
+#include <ostream>
+#include <istream>
+#include <bits/stream_iterator.h>
+#include <bits/streambuf_iterator.h>
+#include <bits/range_access.h>
+
+#endif /* _GLIBCXX_ITERATOR */
diff --git a/gcc-4.9/libstdc++-v3/include/std/limits b/gcc-4.9/libstdc++-v3/include/std/limits
new file mode 100644
index 0000000..f39821e
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/limits
@@ -0,0 +1,1786 @@
+// The template and inlines for the numeric_limits classes. -*- C++ -*-
+
+// Copyright (C) 1999-2014 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/limits
+ * This is a Standard C++ Library header.
+ */
+
+// Note: this is not a conforming implementation.
+// Written by Gabriel Dos Reis <gdr@codesourcery.com>
+
+//
+// ISO 14882:1998
+// 18.2.1
+//
+
+#ifndef _GLIBCXX_NUMERIC_LIMITS
+#define _GLIBCXX_NUMERIC_LIMITS 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+
+//
+// The numeric_limits<> traits document implementation-defined aspects
+// of fundamental arithmetic data types (integers and floating points).
+// From Standard C++ point of view, there are 14 such types:
+// * integers
+// bool (1)
+// char, signed char, unsigned char, wchar_t (4)
+// short, unsigned short (2)
+// int, unsigned (2)
+// long, unsigned long (2)
+//
+// * floating points
+// float (1)
+// double (1)
+// long double (1)
+//
+// GNU C++ understands (where supported by the host C-library)
+// * integer
+// long long, unsigned long long (2)
+//
+// which brings us to 16 fundamental arithmetic data types in GNU C++.
+//
+//
+// Since a numeric_limits<> is a bit tricky to get right, we rely on
+// an interface composed of macros which should be defined in config/os
+// or config/cpu when they differ from the generic (read arbitrary)
+// definitions given here.
+//
+
+// These values can be overridden in the target configuration file.
+// The default values are appropriate for many 32-bit targets.
+
+// GCC only intrinsically supports modulo integral types. The only remaining
+// integral exceptional values is division by zero. Only targets that do not
+// signal division by zero in some "hard to ignore" way should use false.
+#ifndef __glibcxx_integral_traps
+# define __glibcxx_integral_traps true
+#endif
+
+// float
+//
+
+// Default values. Should be overridden in configuration files if necessary.
+
+#ifndef __glibcxx_float_has_denorm_loss
+# define __glibcxx_float_has_denorm_loss false
+#endif
+#ifndef __glibcxx_float_traps
+# define __glibcxx_float_traps false
+#endif
+#ifndef __glibcxx_float_tinyness_before
+# define __glibcxx_float_tinyness_before false
+#endif
+
+// double
+
+// Default values. Should be overridden in configuration files if necessary.
+
+#ifndef __glibcxx_double_has_denorm_loss
+# define __glibcxx_double_has_denorm_loss false
+#endif
+#ifndef __glibcxx_double_traps
+# define __glibcxx_double_traps false
+#endif
+#ifndef __glibcxx_double_tinyness_before
+# define __glibcxx_double_tinyness_before false
+#endif
+
+// long double
+
+// Default values. Should be overridden in configuration files if necessary.
+
+#ifndef __glibcxx_long_double_has_denorm_loss
+# define __glibcxx_long_double_has_denorm_loss false
+#endif
+#ifndef __glibcxx_long_double_traps
+# define __glibcxx_long_double_traps false
+#endif
+#ifndef __glibcxx_long_double_tinyness_before
+# define __glibcxx_long_double_tinyness_before false
+#endif
+
+// You should not need to define any macros below this point.
+
+#define __glibcxx_signed(T) ((T)(-1) < 0)
+
+#define __glibcxx_min(T) \
+ (__glibcxx_signed (T) ? -__glibcxx_max (T) - 1 : (T)0)
+
+#define __glibcxx_max(T) \
+ (__glibcxx_signed (T) ? \
+ (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0)
+
+#define __glibcxx_digits(T) \
+ (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T))
+
+// The fraction 643/2136 approximates log10(2) to 7 significant digits.
+#define __glibcxx_digits10(T) \
+ (__glibcxx_digits (T) * 643L / 2136)
+
+#define __glibcxx_max_digits10(T) \
+ (2 + (T) * 643L / 2136)
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @brief Describes the rounding style for floating-point types.
+ *
+ * This is used in the std::numeric_limits class.
+ */
+ enum float_round_style
+ {
+ round_indeterminate = -1, /// Intermediate.
+ round_toward_zero = 0, /// To zero.
+ round_to_nearest = 1, /// To the nearest representable value.
+ round_toward_infinity = 2, /// To infinity.
+ round_toward_neg_infinity = 3 /// To negative infinity.
+ };
+
+ /**
+ * @brief Describes the denormalization for floating-point types.
+ *
+ * These values represent the presence or absence of a variable number
+ * of exponent bits. This type is used in the std::numeric_limits class.
+ */
+ enum float_denorm_style
+ {
+ /// Indeterminate at compile time whether denormalized values are allowed.
+ denorm_indeterminate = -1,
+ /// The type does not allow denormalized values.
+ denorm_absent = 0,
+ /// The type allows denormalized values.
+ denorm_present = 1
+ };
+
+ /**
+ * @brief Part of std::numeric_limits.
+ *
+ * The @c static @c const members are usable as integral constant
+ * expressions.
+ *
+ * @note This is a separate class for purposes of efficiency; you
+ * should only access these members as part of an instantiation
+ * of the std::numeric_limits class.
+ */
+ struct __numeric_limits_base
+ {
+ /** This will be true for all fundamental types (which have
+ specializations), and false for everything else. */
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = false;
+
+ /** The number of @c radix digits that be represented without change: for
+ integer types, the number of non-sign bits in the mantissa; for
+ floating types, the number of @c radix digits in the mantissa. */
+ static _GLIBCXX_USE_CONSTEXPR int digits = 0;
+
+ /** The number of base 10 digits that can be represented without change. */
+ static _GLIBCXX_USE_CONSTEXPR int digits10 = 0;
+
+#if __cplusplus >= 201103L
+ /** The number of base 10 digits required to ensure that values which
+ differ are always differentiated. */
+ static constexpr int max_digits10 = 0;
+#endif
+
+ /** True if the type is signed. */
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
+
+ /** True if the type is integer. */
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = false;
+
+ /** True if the type uses an exact representation. All integer types are
+ exact, but not all exact types are integer. For example, rational and
+ fixed-exponent representations are exact but not integer. */
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = false;
+
+ /** For integer types, specifies the base of the representation. For
+ floating types, specifies the base of the exponent representation. */
+ static _GLIBCXX_USE_CONSTEXPR int radix = 0;
+
+ /** The minimum negative integer such that @c radix raised to the power of
+ (one less than that integer) is a normalized floating point number. */
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+
+ /** The minimum negative integer such that 10 raised to that power is in
+ the range of normalized floating point numbers. */
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+
+ /** The maximum positive integer such that @c radix raised to the power of
+ (one less than that integer) is a representable finite floating point
+ number. */
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+
+ /** The maximum positive integer such that 10 raised to that power is in
+ the range of representable finite floating point numbers. */
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ /** True if the type has a representation for positive infinity. */
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+
+ /** True if the type has a representation for a quiet (non-signaling)
+ Not a Number. */
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+
+ /** True if the type has a representation for a signaling
+ Not a Number. */
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+
+ /** See std::float_denorm_style for more information. */
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
+
+ /** True if loss of accuracy is detected as a denormalization loss,
+ rather than as an inexact result. */
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ /** True if-and-only-if the type adheres to the IEC 559 standard, also
+ known as IEEE 754. (Only makes sense for floating point types.) */
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+
+ /** True if the set of values representable by the type is
+ finite. All built-in types are bounded, this member would be
+ false for arbitrary precision types. */
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = false;
+
+ /** True if the type is @e modulo. A type is modulo if, for any
+ operation involving +, -, or * on values of that type whose
+ result would fall outside the range [min(),max()], the value
+ returned differs from the true value by an integer multiple of
+ max() - min() + 1. On most machines, this is false for floating
+ types, true for unsigned integers, and true for signed integers.
+ See PR22200 about signed integers. */
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ /** True if trapping is implemented for this type. */
+ static _GLIBCXX_USE_CONSTEXPR bool traps = false;
+
+ /** True if tininess is detected before rounding. (see IEC 559) */
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+
+ /** See std::float_round_style for more information. This is only
+ meaningful for floating types; integer types will all be
+ round_toward_zero. */
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style =
+ round_toward_zero;
+ };
+
+ /**
+ * @brief Properties of fundamental types.
+ *
+ * This class allows a program to obtain information about the
+ * representation of a fundamental type on a given platform. For
+ * non-fundamental types, the functions will return 0 and the data
+ * members will all be @c false.
+ *
+ * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are
+ * noted, but not incorporated in this documented (yet).
+ */
+ template<typename _Tp>
+ struct numeric_limits : public __numeric_limits_base
+ {
+ /** The minimum finite value, or for floating types with
+ denormalization, the minimum positive normalized value. */
+ static _GLIBCXX_CONSTEXPR _Tp
+ min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
+
+ /** The maximum finite value. */
+ static _GLIBCXX_CONSTEXPR _Tp
+ max() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
+
+#if __cplusplus >= 201103L
+ /** A finite value x such that there is no other finite value y
+ * where y < x. */
+ static constexpr _Tp
+ lowest() noexcept { return _Tp(); }
+#endif
+
+ /** The @e machine @e epsilon: the difference between 1 and the least
+ value greater than 1 that is representable. */
+ static _GLIBCXX_CONSTEXPR _Tp
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
+
+ /** The maximum rounding error measurement (see LIA-1). */
+ static _GLIBCXX_CONSTEXPR _Tp
+ round_error() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
+
+ /** The representation of positive infinity, if @c has_infinity. */
+ static _GLIBCXX_CONSTEXPR _Tp
+ infinity() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
+
+ /** The representation of a quiet Not a Number,
+ if @c has_quiet_NaN. */
+ static _GLIBCXX_CONSTEXPR _Tp
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
+
+ /** The representation of a signaling Not a Number, if
+ @c has_signaling_NaN. */
+ static _GLIBCXX_CONSTEXPR _Tp
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
+
+ /** The minimum positive denormalized value. For types where
+ @c has_denorm is false, this is the minimum positive normalized
+ value. */
+ static _GLIBCXX_CONSTEXPR _Tp
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
+ };
+
+#if __cplusplus >= 201103L
+ template<typename _Tp>
+ struct numeric_limits<const _Tp>
+ : public numeric_limits<_Tp> { };
+
+ template<typename _Tp>
+ struct numeric_limits<volatile _Tp>
+ : public numeric_limits<_Tp> { };
+
+ template<typename _Tp>
+ struct numeric_limits<const volatile _Tp>
+ : public numeric_limits<_Tp> { };
+#endif
+
+ // Now there follow 16 explicit specializations. Yes, 16. Make sure
+ // you get the count right. (18 in c++0x mode)
+
+ /// numeric_limits<bool> specialization.
+ template<>
+ struct numeric_limits<bool>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR bool
+ min() _GLIBCXX_USE_NOEXCEPT { return false; }
+
+ static _GLIBCXX_CONSTEXPR bool
+ max() _GLIBCXX_USE_NOEXCEPT { return true; }
+
+#if __cplusplus >= 201103L
+ static constexpr bool
+ lowest() noexcept { return min(); }
+#endif
+ static _GLIBCXX_USE_CONSTEXPR int digits = 1;
+ static _GLIBCXX_USE_CONSTEXPR int digits10 = 0;
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR bool
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return false; }
+
+ static _GLIBCXX_CONSTEXPR bool
+ round_error() _GLIBCXX_USE_NOEXCEPT { return false; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR bool
+ infinity() _GLIBCXX_USE_NOEXCEPT { return false; }
+
+ static _GLIBCXX_CONSTEXPR bool
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return false; }
+
+ static _GLIBCXX_CONSTEXPR bool
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return false; }
+
+ static _GLIBCXX_CONSTEXPR bool
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return false; }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ // It is not clear what it means for a boolean type to trap.
+ // This is a DR on the LWG issue list. Here, I use integer
+ // promotion semantics.
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<char> specialization.
+ template<>
+ struct numeric_limits<char>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR char
+ min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min(char); }
+
+ static _GLIBCXX_CONSTEXPR char
+ max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max(char); }
+
+#if __cplusplus >= 201103L
+ static constexpr char
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (char);
+ static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (char);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = __glibcxx_signed (char);
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR char
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR char
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR
+ char infinity() _GLIBCXX_USE_NOEXCEPT { return char(); }
+
+ static _GLIBCXX_CONSTEXPR char
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); }
+
+ static _GLIBCXX_CONSTEXPR char
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); }
+
+ static _GLIBCXX_CONSTEXPR char
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<char>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<signed char> specialization.
+ template<>
+ struct numeric_limits<signed char>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR signed char
+ min() _GLIBCXX_USE_NOEXCEPT { return -__SCHAR_MAX__ - 1; }
+
+ static _GLIBCXX_CONSTEXPR signed char
+ max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__; }
+
+#if __cplusplus >= 201103L
+ static constexpr signed char
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (signed char);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (signed char);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR signed char
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR signed char
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR signed char
+ infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<signed char>(0); }
+
+ static _GLIBCXX_CONSTEXPR signed char
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<signed char>(0); }
+
+ static _GLIBCXX_CONSTEXPR signed char
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<signed char>(0); }
+
+ static _GLIBCXX_CONSTEXPR signed char
+ denorm_min() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<signed char>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<unsigned char> specialization.
+ template<>
+ struct numeric_limits<unsigned char>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR unsigned char
+ min() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned char
+ max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__ * 2U + 1; }
+
+#if __cplusplus >= 201103L
+ static constexpr unsigned char
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits
+ = __glibcxx_digits (unsigned char);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (unsigned char);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR unsigned char
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned char
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR unsigned char
+ infinity() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned char>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned char
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned char>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned char
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned char>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned char
+ denorm_min() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned char>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<wchar_t> specialization.
+ template<>
+ struct numeric_limits<wchar_t>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR wchar_t
+ min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
+
+ static _GLIBCXX_CONSTEXPR wchar_t
+ max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (wchar_t); }
+
+#if __cplusplus >= 201103L
+ static constexpr wchar_t
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (wchar_t);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (wchar_t);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = __glibcxx_signed (wchar_t);
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR wchar_t
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR wchar_t
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR wchar_t
+ infinity() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); }
+
+ static _GLIBCXX_CONSTEXPR wchar_t
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); }
+
+ static _GLIBCXX_CONSTEXPR wchar_t
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); }
+
+ static _GLIBCXX_CONSTEXPR wchar_t
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+#if __cplusplus >= 201103L
+ /// numeric_limits<char16_t> specialization.
+ template<>
+ struct numeric_limits<char16_t>
+ {
+ static constexpr bool is_specialized = true;
+
+ static constexpr char16_t
+ min() noexcept { return __glibcxx_min (char16_t); }
+
+ static constexpr char16_t
+ max() noexcept { return __glibcxx_max (char16_t); }
+
+ static constexpr char16_t
+ lowest() noexcept { return min(); }
+
+ static constexpr int digits = __glibcxx_digits (char16_t);
+ static constexpr int digits10 = __glibcxx_digits10 (char16_t);
+ static constexpr int max_digits10 = 0;
+ static constexpr bool is_signed = __glibcxx_signed (char16_t);
+ static constexpr bool is_integer = true;
+ static constexpr bool is_exact = true;
+ static constexpr int radix = 2;
+
+ static constexpr char16_t
+ epsilon() noexcept { return 0; }
+
+ static constexpr char16_t
+ round_error() noexcept { return 0; }
+
+ static constexpr int min_exponent = 0;
+ static constexpr int min_exponent10 = 0;
+ static constexpr int max_exponent = 0;
+ static constexpr int max_exponent10 = 0;
+
+ static constexpr bool has_infinity = false;
+ static constexpr bool has_quiet_NaN = false;
+ static constexpr bool has_signaling_NaN = false;
+ static constexpr float_denorm_style has_denorm = denorm_absent;
+ static constexpr bool has_denorm_loss = false;
+
+ static constexpr char16_t
+ infinity() noexcept { return char16_t(); }
+
+ static constexpr char16_t
+ quiet_NaN() noexcept { return char16_t(); }
+
+ static constexpr char16_t
+ signaling_NaN() noexcept { return char16_t(); }
+
+ static constexpr char16_t
+ denorm_min() noexcept { return char16_t(); }
+
+ static constexpr bool is_iec559 = false;
+ static constexpr bool is_bounded = true;
+ static constexpr bool is_modulo = !is_signed;
+
+ static constexpr bool traps = __glibcxx_integral_traps;
+ static constexpr bool tinyness_before = false;
+ static constexpr float_round_style round_style = round_toward_zero;
+ };
+
+ /// numeric_limits<char32_t> specialization.
+ template<>
+ struct numeric_limits<char32_t>
+ {
+ static constexpr bool is_specialized = true;
+
+ static constexpr char32_t
+ min() noexcept { return __glibcxx_min (char32_t); }
+
+ static constexpr char32_t
+ max() noexcept { return __glibcxx_max (char32_t); }
+
+ static constexpr char32_t
+ lowest() noexcept { return min(); }
+
+ static constexpr int digits = __glibcxx_digits (char32_t);
+ static constexpr int digits10 = __glibcxx_digits10 (char32_t);
+ static constexpr int max_digits10 = 0;
+ static constexpr bool is_signed = __glibcxx_signed (char32_t);
+ static constexpr bool is_integer = true;
+ static constexpr bool is_exact = true;
+ static constexpr int radix = 2;
+
+ static constexpr char32_t
+ epsilon() noexcept { return 0; }
+
+ static constexpr char32_t
+ round_error() noexcept { return 0; }
+
+ static constexpr int min_exponent = 0;
+ static constexpr int min_exponent10 = 0;
+ static constexpr int max_exponent = 0;
+ static constexpr int max_exponent10 = 0;
+
+ static constexpr bool has_infinity = false;
+ static constexpr bool has_quiet_NaN = false;
+ static constexpr bool has_signaling_NaN = false;
+ static constexpr float_denorm_style has_denorm = denorm_absent;
+ static constexpr bool has_denorm_loss = false;
+
+ static constexpr char32_t
+ infinity() noexcept { return char32_t(); }
+
+ static constexpr char32_t
+ quiet_NaN() noexcept { return char32_t(); }
+
+ static constexpr char32_t
+ signaling_NaN() noexcept { return char32_t(); }
+
+ static constexpr char32_t
+ denorm_min() noexcept { return char32_t(); }
+
+ static constexpr bool is_iec559 = false;
+ static constexpr bool is_bounded = true;
+ static constexpr bool is_modulo = !is_signed;
+
+ static constexpr bool traps = __glibcxx_integral_traps;
+ static constexpr bool tinyness_before = false;
+ static constexpr float_round_style round_style = round_toward_zero;
+ };
+#endif
+
+ /// numeric_limits<short> specialization.
+ template<>
+ struct numeric_limits<short>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR short
+ min() _GLIBCXX_USE_NOEXCEPT { return -__SHRT_MAX__ - 1; }
+
+ static _GLIBCXX_CONSTEXPR short
+ max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__; }
+
+#if __cplusplus >= 201103L
+ static constexpr short
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (short);
+ static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (short);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR short
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR short
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR short
+ infinity() _GLIBCXX_USE_NOEXCEPT { return short(); }
+
+ static _GLIBCXX_CONSTEXPR short
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); }
+
+ static _GLIBCXX_CONSTEXPR short
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); }
+
+ static _GLIBCXX_CONSTEXPR short
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return short(); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<unsigned short> specialization.
+ template<>
+ struct numeric_limits<unsigned short>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR unsigned short
+ min() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned short
+ max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__ * 2U + 1; }
+
+#if __cplusplus >= 201103L
+ static constexpr unsigned short
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits
+ = __glibcxx_digits (unsigned short);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (unsigned short);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR unsigned short
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned short
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR unsigned short
+ infinity() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned short>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned short
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned short>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned short
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned short>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned short
+ denorm_min() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned short>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<int> specialization.
+ template<>
+ struct numeric_limits<int>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR int
+ min() _GLIBCXX_USE_NOEXCEPT { return -__INT_MAX__ - 1; }
+
+ static _GLIBCXX_CONSTEXPR int
+ max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__; }
+
+#if __cplusplus >= 201103L
+ static constexpr int
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (int);
+ static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (int);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR int
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR int
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR int
+ infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); }
+
+ static _GLIBCXX_CONSTEXPR int
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); }
+
+ static _GLIBCXX_CONSTEXPR int
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); }
+
+ static _GLIBCXX_CONSTEXPR int
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<unsigned int> specialization.
+ template<>
+ struct numeric_limits<unsigned int>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR unsigned int
+ min() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned int
+ max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__ * 2U + 1; }
+
+#if __cplusplus >= 201103L
+ static constexpr unsigned int
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits
+ = __glibcxx_digits (unsigned int);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (unsigned int);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR unsigned int
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned int
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR unsigned int
+ infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned int>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned int
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned int>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned int
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned int>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned int
+ denorm_min() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned int>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<long> specialization.
+ template<>
+ struct numeric_limits<long>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR long
+ min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_MAX__ - 1; }
+
+ static _GLIBCXX_CONSTEXPR long
+ max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__; }
+
+#if __cplusplus >= 201103L
+ static constexpr long
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (long);
+ static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (long);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR long
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR long
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR long
+ infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); }
+
+ static _GLIBCXX_CONSTEXPR long
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); }
+
+ static _GLIBCXX_CONSTEXPR long
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); }
+
+ static _GLIBCXX_CONSTEXPR long
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<unsigned long> specialization.
+ template<>
+ struct numeric_limits<unsigned long>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR unsigned long
+ min() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned long
+ max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__ * 2UL + 1; }
+
+#if __cplusplus >= 201103L
+ static constexpr unsigned long
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits
+ = __glibcxx_digits (unsigned long);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (unsigned long);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR unsigned long
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned long
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR unsigned long
+ infinity() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned long>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned long
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned long>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned long
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned long>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned long
+ denorm_min() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned long>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<long long> specialization.
+ template<>
+ struct numeric_limits<long long>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR long long
+ min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_LONG_MAX__ - 1; }
+
+ static _GLIBCXX_CONSTEXPR long long
+ max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__; }
+
+#if __cplusplus >= 201103L
+ static constexpr long long
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits
+ = __glibcxx_digits (long long);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (long long);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR long long
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR long long
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR long long
+ infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); }
+
+ static _GLIBCXX_CONSTEXPR long long
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); }
+
+ static _GLIBCXX_CONSTEXPR long long
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<long long>(0); }
+
+ static _GLIBCXX_CONSTEXPR long long
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<unsigned long long> specialization.
+ template<>
+ struct numeric_limits<unsigned long long>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR unsigned long long
+ min() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned long long
+ max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__ * 2ULL + 1; }
+
+#if __cplusplus >= 201103L
+ static constexpr unsigned long long
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits
+ = __glibcxx_digits (unsigned long long);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (unsigned long long);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR unsigned long long
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned long long
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR unsigned long long
+ infinity() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned long long>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned long long
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned long long>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned long long
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned long long>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned long long
+ denorm_min() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned long long>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
+ /// numeric_limits<__int128> specialization.
+ template<>
+ struct numeric_limits<__int128>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR __int128
+ min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (__int128); }
+
+ static _GLIBCXX_CONSTEXPR __int128
+ max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (__int128); }
+
+#if __cplusplus >= 201103L
+ static constexpr __int128
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits
+ = __glibcxx_digits (__int128);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (__int128);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR __int128
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR __int128
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR __int128
+ infinity() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<__int128>(0); }
+
+ static _GLIBCXX_CONSTEXPR __int128
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<__int128>(0); }
+
+ static _GLIBCXX_CONSTEXPR __int128
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<__int128>(0); }
+
+ static _GLIBCXX_CONSTEXPR __int128
+ denorm_min() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<__int128>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps
+ = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+
+ /// numeric_limits<unsigned __int128> specialization.
+ template<>
+ struct numeric_limits<unsigned __int128>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR unsigned __int128
+ min() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned __int128
+ max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (unsigned __int128); }
+
+#if __cplusplus >= 201103L
+ static constexpr unsigned __int128
+ lowest() noexcept { return min(); }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits
+ = __glibcxx_digits (unsigned __int128);
+ static _GLIBCXX_USE_CONSTEXPR int digits10
+ = __glibcxx_digits10 (unsigned __int128);
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10 = 0;
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
+ static _GLIBCXX_USE_CONSTEXPR int radix = 2;
+
+ static _GLIBCXX_CONSTEXPR unsigned __int128
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_CONSTEXPR unsigned __int128
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
+
+ static _GLIBCXX_CONSTEXPR unsigned __int128
+ infinity() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned __int128>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned __int128
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned __int128>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned __int128
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned __int128>(0); }
+
+ static _GLIBCXX_CONSTEXPR unsigned __int128
+ denorm_min() _GLIBCXX_USE_NOEXCEPT
+ { return static_cast<unsigned __int128>(0); }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_toward_zero;
+ };
+#endif
+
+ /// numeric_limits<float> specialization.
+ template<>
+ struct numeric_limits<float>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR float
+ min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MIN__; }
+
+ static _GLIBCXX_CONSTEXPR float
+ max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
+
+#if __cplusplus >= 201103L
+ static constexpr float
+ lowest() noexcept { return -__FLT_MAX__; }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits = __FLT_MANT_DIG__;
+ static _GLIBCXX_USE_CONSTEXPR int digits10 = __FLT_DIG__;
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10
+ = __glibcxx_max_digits10 (__FLT_MANT_DIG__);
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = false;
+ static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__;
+
+ static _GLIBCXX_CONSTEXPR float
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return __FLT_EPSILON__; }
+
+ static _GLIBCXX_CONSTEXPR float
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5F; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = __FLT_MIN_EXP__;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __FLT_MIN_10_EXP__;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = __FLT_MAX_EXP__;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __FLT_MAX_10_EXP__;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __FLT_HAS_INFINITY__;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss
+ = __glibcxx_float_has_denorm_loss;
+
+ static _GLIBCXX_CONSTEXPR float
+ infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_valf(); }
+
+ static _GLIBCXX_CONSTEXPR float
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanf(""); }
+
+ static _GLIBCXX_CONSTEXPR float
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansf(""); }
+
+ static _GLIBCXX_CONSTEXPR float
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return __FLT_DENORM_MIN__; }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559
+ = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_float_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before
+ = __glibcxx_float_tinyness_before;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_to_nearest;
+ };
+
+#undef __glibcxx_float_has_denorm_loss
+#undef __glibcxx_float_traps
+#undef __glibcxx_float_tinyness_before
+
+ /// numeric_limits<double> specialization.
+ template<>
+ struct numeric_limits<double>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR double
+ min() _GLIBCXX_USE_NOEXCEPT { return __DBL_MIN__; }
+
+ static _GLIBCXX_CONSTEXPR double
+ max() _GLIBCXX_USE_NOEXCEPT { return __DBL_MAX__; }
+
+#if __cplusplus >= 201103L
+ static constexpr double
+ lowest() noexcept { return -__DBL_MAX__; }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits = __DBL_MANT_DIG__;
+ static _GLIBCXX_USE_CONSTEXPR int digits10 = __DBL_DIG__;
+#if __cplusplus >= 201103L
+ static constexpr int max_digits10
+ = __glibcxx_max_digits10 (__DBL_MANT_DIG__);
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = false;
+ static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__;
+
+ static _GLIBCXX_CONSTEXPR double
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return __DBL_EPSILON__; }
+
+ static _GLIBCXX_CONSTEXPR double
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = __DBL_MIN_EXP__;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __DBL_MIN_10_EXP__;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = __DBL_MAX_EXP__;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __DBL_MAX_10_EXP__;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __DBL_HAS_INFINITY__;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss
+ = __glibcxx_double_has_denorm_loss;
+
+ static _GLIBCXX_CONSTEXPR double
+ infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_val(); }
+
+ static _GLIBCXX_CONSTEXPR double
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nan(""); }
+
+ static _GLIBCXX_CONSTEXPR double
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nans(""); }
+
+ static _GLIBCXX_CONSTEXPR double
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return __DBL_DENORM_MIN__; }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559
+ = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_double_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before
+ = __glibcxx_double_tinyness_before;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
+ = round_to_nearest;
+ };
+
+#undef __glibcxx_double_has_denorm_loss
+#undef __glibcxx_double_traps
+#undef __glibcxx_double_tinyness_before
+
+ /// numeric_limits<long double> specialization.
+ template<>
+ struct numeric_limits<long double>
+ {
+ static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
+
+ static _GLIBCXX_CONSTEXPR long double
+ min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MIN__; }
+
+ static _GLIBCXX_CONSTEXPR long double
+ max() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MAX__; }
+
+#if __cplusplus >= 201103L
+ static constexpr long double
+ lowest() noexcept { return -__LDBL_MAX__; }
+#endif
+
+ static _GLIBCXX_USE_CONSTEXPR int digits = __LDBL_MANT_DIG__;
+ static _GLIBCXX_USE_CONSTEXPR int digits10 = __LDBL_DIG__;
+#if __cplusplus >= 201103L
+ static _GLIBCXX_USE_CONSTEXPR int max_digits10
+ = __glibcxx_max_digits10 (__LDBL_MANT_DIG__);
+#endif
+ static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_integer = false;
+ static _GLIBCXX_USE_CONSTEXPR bool is_exact = false;
+ static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__;
+
+ static _GLIBCXX_CONSTEXPR long double
+ epsilon() _GLIBCXX_USE_NOEXCEPT { return __LDBL_EPSILON__; }
+
+ static _GLIBCXX_CONSTEXPR long double
+ round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5L; }
+
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent = __LDBL_MIN_EXP__;
+ static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __LDBL_MIN_10_EXP__;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent = __LDBL_MAX_EXP__;
+ static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __LDBL_MAX_10_EXP__;
+
+ static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __LDBL_HAS_INFINITY__;
+ static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
+ static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN;
+ static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
+ = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
+ static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss
+ = __glibcxx_long_double_has_denorm_loss;
+
+ static _GLIBCXX_CONSTEXPR long double
+ infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_vall(); }
+
+ static _GLIBCXX_CONSTEXPR long double
+ quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanl(""); }
+
+ static _GLIBCXX_CONSTEXPR long double
+ signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansl(""); }
+
+ static _GLIBCXX_CONSTEXPR long double
+ denorm_min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_DENORM_MIN__; }
+
+ static _GLIBCXX_USE_CONSTEXPR bool is_iec559
+ = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
+ static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
+ static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
+
+ static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_long_double_traps;
+ static _GLIBCXX_USE_CONSTEXPR bool tinyness_before =
+ __glibcxx_long_double_tinyness_before;
+ static _GLIBCXX_USE_CONSTEXPR float_round_style round_style =
+ round_to_nearest;
+ };
+
+#undef __glibcxx_long_double_has_denorm_loss
+#undef __glibcxx_long_double_traps
+#undef __glibcxx_long_double_tinyness_before
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#undef __glibcxx_signed
+#undef __glibcxx_min
+#undef __glibcxx_max
+#undef __glibcxx_digits
+#undef __glibcxx_digits10
+#undef __glibcxx_max_digits10
+
+#endif // _GLIBCXX_NUMERIC_LIMITS
diff --git a/gcc-4.9/libstdc++-v3/include/std/list b/gcc-4.9/libstdc++-v3/include/std/list
new file mode 100644
index 0000000..c3efc43
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/list
@@ -0,0 +1,75 @@
+// <list> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/list
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_LIST
+#define _GLIBCXX_LIST 1
+
+#pragma GCC system_header
+
+#include <bits/stl_algobase.h>
+#include <bits/allocator.h>
+#include <bits/range_access.h>
+#include <bits/stl_list.h>
+#include <bits/list.tcc>
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/list>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/list>
+#endif
+
+#endif /* _GLIBCXX_LIST */
+
diff --git a/gcc-4.9/libstdc++-v3/include/std/locale b/gcc-4.9/libstdc++-v3/include/std/locale
new file mode 100644
index 0000000..c61c220
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/locale
@@ -0,0 +1,43 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/>.
+
+//
+// ISO C++ 14882: 22.1 Locales
+//
+
+/** @file include/locale
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_LOCALE
+#define _GLIBCXX_LOCALE 1
+
+#pragma GCC system_header
+
+#include <bits/localefwd.h>
+#include <bits/locale_classes.h>
+#include <bits/locale_facets.h>
+#include <bits/locale_facets_nonio.h>
+
+#endif /* _GLIBCXX_LOCALE */
diff --git a/gcc-4.9/libstdc++-v3/include/std/map b/gcc-4.9/libstdc++-v3/include/std/map
new file mode 100644
index 0000000..6a3b2fb
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/map
@@ -0,0 +1,73 @@
+// <map> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/map
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_MAP
+#define _GLIBCXX_MAP 1
+
+#pragma GCC system_header
+
+#include <bits/stl_tree.h>
+#include <bits/stl_map.h>
+#include <bits/stl_multimap.h>
+#include <bits/range_access.h>
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/map>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/map>
+#endif
+
+#endif /* _GLIBCXX_MAP */
diff --git a/gcc-4.9/libstdc++-v3/include/std/memory b/gcc-4.9/libstdc++-v3/include/std/memory
new file mode 100644
index 0000000..dafec0c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/memory
@@ -0,0 +1,90 @@
+// <memory> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ * Copyright (c) 1997-1999
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ */
+
+/** @file include/memory
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_MEMORY
+#define _GLIBCXX_MEMORY 1
+
+#pragma GCC system_header
+
+/**
+ * @defgroup memory Memory
+ * @ingroup utilities
+ *
+ * Components for memory allocation, deallocation, and management.
+ */
+
+/**
+ * @defgroup pointer_abstractions Pointer Abstractions
+ * @ingroup memory
+ *
+ * Smart pointers, etc.
+ */
+
+#include <bits/stl_algobase.h>
+#include <bits/allocator.h>
+#include <bits/stl_construct.h>
+#include <bits/stl_uninitialized.h>
+#include <bits/stl_tempbuf.h>
+#include <bits/stl_raw_storage_iter.h>
+
+#if __cplusplus >= 201103L
+# include <exception> // std::exception
+# include <typeinfo> // std::type_info in get_deleter
+# include <iosfwd> // std::basic_ostream
+# include <ext/atomicity.h>
+# include <ext/concurrence.h>
+# include <bits/functexcept.h>
+# include <bits/stl_function.h> // std::less
+# include <bits/uses_allocator.h>
+# include <type_traits>
+# include <functional>
+# include <debug/debug.h>
+# include <bits/unique_ptr.h>
+# include <bits/shared_ptr.h>
+# if _GLIBCXX_USE_DEPRECATED
+# include <backward/auto_ptr.h>
+# endif
+#else
+# include <backward/auto_ptr.h>
+#endif
+
+#endif /* _GLIBCXX_MEMORY */
diff --git a/gcc-4.9/libstdc++-v3/include/std/mutex b/gcc-4.9/libstdc++-v3/include/std/mutex
new file mode 100644
index 0000000..0b481d6
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/mutex
@@ -0,0 +1,767 @@
+// <mutex> -*- C++ -*-
+
+// Copyright (C) 2003-2014 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/mutex
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_MUTEX
+#define _GLIBCXX_MUTEX 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <tuple>
+#include <chrono>
+#include <exception>
+#include <type_traits>
+#include <functional>
+#include <system_error>
+#include <bits/functexcept.h>
+#include <bits/gthr.h>
+#include <bits/move.h> // for std::swap
+
+#ifdef _GLIBCXX_USE_C99_STDINT_TR1
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+#ifdef _GLIBCXX_HAS_GTHREADS
+ // Common base class for std::mutex and std::timed_mutex
+ class __mutex_base
+ {
+ protected:
+ typedef __gthread_mutex_t __native_type;
+
+#ifdef __GTHREAD_MUTEX_INIT
+ __native_type _M_mutex = __GTHREAD_MUTEX_INIT;
+
+ constexpr __mutex_base() noexcept = default;
+#else
+ __native_type _M_mutex;
+
+ __mutex_base() noexcept
+ {
+ // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
+ __GTHREAD_MUTEX_INIT_FUNCTION(&_M_mutex);
+ }
+
+ ~__mutex_base() noexcept { __gthread_mutex_destroy(&_M_mutex); }
+#endif
+
+ __mutex_base(const __mutex_base&) = delete;
+ __mutex_base& operator=(const __mutex_base&) = delete;
+ };
+
+ // Common base class for std::recursive_mutex and std::recursive_timed_mutex
+ class __recursive_mutex_base
+ {
+ protected:
+ typedef __gthread_recursive_mutex_t __native_type;
+
+ __recursive_mutex_base(const __recursive_mutex_base&) = delete;
+ __recursive_mutex_base& operator=(const __recursive_mutex_base&) = delete;
+
+#ifdef __GTHREAD_RECURSIVE_MUTEX_INIT
+ __native_type _M_mutex = __GTHREAD_RECURSIVE_MUTEX_INIT;
+
+ __recursive_mutex_base() = default;
+#else
+ __native_type _M_mutex;
+
+ __recursive_mutex_base()
+ {
+ // XXX EAGAIN, ENOMEM, EPERM, EBUSY(may), EINVAL(may)
+ __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION(&_M_mutex);
+ }
+
+ ~__recursive_mutex_base()
+ { __gthread_recursive_mutex_destroy(&_M_mutex); }
+#endif
+ };
+
+ /**
+ * @defgroup mutexes Mutexes
+ * @ingroup concurrency
+ *
+ * Classes for mutex support.
+ * @{
+ */
+
+ /// mutex
+ class mutex : private __mutex_base
+ {
+ public:
+ typedef __native_type* native_handle_type;
+
+#ifdef __GTHREAD_MUTEX_INIT
+ constexpr
+#endif
+ mutex() noexcept = default;
+ ~mutex() = default;
+
+ mutex(const mutex&) = delete;
+ mutex& operator=(const mutex&) = delete;
+
+ void
+ lock()
+ {
+ int __e = __gthread_mutex_lock(&_M_mutex);
+
+ // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may)
+ if (__e)
+ __throw_system_error(__e);
+ }
+
+ bool
+ try_lock() noexcept
+ {
+ // XXX EINVAL, EAGAIN, EBUSY
+ return !__gthread_mutex_trylock(&_M_mutex);
+ }
+
+ void
+ unlock()
+ {
+ // XXX EINVAL, EAGAIN, EPERM
+ __gthread_mutex_unlock(&_M_mutex);
+ }
+
+ native_handle_type
+ native_handle()
+ { return &_M_mutex; }
+ };
+
+ /// recursive_mutex
+ class recursive_mutex : private __recursive_mutex_base
+ {
+ public:
+ typedef __native_type* native_handle_type;
+
+ recursive_mutex() = default;
+ ~recursive_mutex() = default;
+
+ recursive_mutex(const recursive_mutex&) = delete;
+ recursive_mutex& operator=(const recursive_mutex&) = delete;
+
+ void
+ lock()
+ {
+ int __e = __gthread_recursive_mutex_lock(&_M_mutex);
+
+ // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may)
+ if (__e)
+ __throw_system_error(__e);
+ }
+
+ bool
+ try_lock() noexcept
+ {
+ // XXX EINVAL, EAGAIN, EBUSY
+ return !__gthread_recursive_mutex_trylock(&_M_mutex);
+ }
+
+ void
+ unlock()
+ {
+ // XXX EINVAL, EAGAIN, EBUSY
+ __gthread_recursive_mutex_unlock(&_M_mutex);
+ }
+
+ native_handle_type
+ native_handle()
+ { return &_M_mutex; }
+ };
+
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+ template<typename _Derived>
+ class __timed_mutex_impl
+ {
+ protected:
+ typedef chrono::high_resolution_clock __clock_t;
+
+ template<typename _Rep, typename _Period>
+ bool
+ _M_try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
+ {
+ using chrono::steady_clock;
+ auto __rt = chrono::duration_cast<steady_clock::duration>(__rtime);
+ if (ratio_greater<steady_clock::period, _Period>())
+ ++__rt;
+ return _M_try_lock_until(steady_clock::now() + __rt);
+ }
+
+ template<typename _Duration>
+ bool
+ _M_try_lock_until(const chrono::time_point<__clock_t,
+ _Duration>& __atime)
+ {
+ auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
+ auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
+
+ __gthread_time_t __ts = {
+ static_cast<std::time_t>(__s.time_since_epoch().count()),
+ static_cast<long>(__ns.count())
+ };
+
+ auto __mutex = static_cast<_Derived*>(this)->native_handle();
+ return !__gthread_mutex_timedlock(__mutex, &__ts);
+ }
+
+ template<typename _Clock, typename _Duration>
+ bool
+ _M_try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
+ {
+ auto __rtime = __atime - _Clock::now();
+ return _M_try_lock_until(__clock_t::now() + __rtime);
+ }
+ };
+
+ /// timed_mutex
+ class timed_mutex
+ : private __mutex_base, public __timed_mutex_impl<timed_mutex>
+ {
+ public:
+ typedef __native_type* native_handle_type;
+
+ timed_mutex() = default;
+ ~timed_mutex() = default;
+
+ timed_mutex(const timed_mutex&) = delete;
+ timed_mutex& operator=(const timed_mutex&) = delete;
+
+ void
+ lock()
+ {
+ int __e = __gthread_mutex_lock(&_M_mutex);
+
+ // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may)
+ if (__e)
+ __throw_system_error(__e);
+ }
+
+ bool
+ try_lock() noexcept
+ {
+ // XXX EINVAL, EAGAIN, EBUSY
+ return !__gthread_mutex_trylock(&_M_mutex);
+ }
+
+ template <class _Rep, class _Period>
+ bool
+ try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
+ { return _M_try_lock_for(__rtime); }
+
+ template <class _Clock, class _Duration>
+ bool
+ try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
+ { return _M_try_lock_until(__atime); }
+
+ void
+ unlock()
+ {
+ // XXX EINVAL, EAGAIN, EBUSY
+ __gthread_mutex_unlock(&_M_mutex);
+ }
+
+ native_handle_type
+ native_handle()
+ { return &_M_mutex; }
+ };
+
+ /// recursive_timed_mutex
+ class recursive_timed_mutex
+ : private __recursive_mutex_base,
+ public __timed_mutex_impl<recursive_timed_mutex>
+ {
+ public:
+ typedef __native_type* native_handle_type;
+
+ recursive_timed_mutex() = default;
+ ~recursive_timed_mutex() = default;
+
+ recursive_timed_mutex(const recursive_timed_mutex&) = delete;
+ recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
+
+ void
+ lock()
+ {
+ int __e = __gthread_recursive_mutex_lock(&_M_mutex);
+
+ // EINVAL, EAGAIN, EBUSY, EINVAL, EDEADLK(may)
+ if (__e)
+ __throw_system_error(__e);
+ }
+
+ bool
+ try_lock() noexcept
+ {
+ // XXX EINVAL, EAGAIN, EBUSY
+ return !__gthread_recursive_mutex_trylock(&_M_mutex);
+ }
+
+ template <class _Rep, class _Period>
+ bool
+ try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
+ { return _M_try_lock_for(__rtime); }
+
+ template <class _Clock, class _Duration>
+ bool
+ try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
+ { return _M_try_lock_until(__atime); }
+
+ void
+ unlock()
+ {
+ // XXX EINVAL, EAGAIN, EBUSY
+ __gthread_recursive_mutex_unlock(&_M_mutex);
+ }
+
+ native_handle_type
+ native_handle()
+ { return &_M_mutex; }
+ };
+#endif
+#endif // _GLIBCXX_HAS_GTHREADS
+
+ /// Do not acquire ownership of the mutex.
+ struct defer_lock_t { };
+
+ /// Try to acquire ownership of the mutex without blocking.
+ struct try_to_lock_t { };
+
+ /// Assume the calling thread has already obtained mutex ownership
+ /// and manage it.
+ struct adopt_lock_t { };
+
+ constexpr defer_lock_t defer_lock { };
+ constexpr try_to_lock_t try_to_lock { };
+ constexpr adopt_lock_t adopt_lock { };
+
+ /// @brief Scoped lock idiom.
+ // Acquire the mutex here with a constructor call, then release with
+ // the destructor call in accordance with RAII style.
+ template<typename _Mutex>
+ class lock_guard
+ {
+ public:
+ typedef _Mutex mutex_type;
+
+ explicit lock_guard(mutex_type& __m) : _M_device(__m)
+ { _M_device.lock(); }
+
+ lock_guard(mutex_type& __m, adopt_lock_t) : _M_device(__m)
+ { } // calling thread owns mutex
+
+ ~lock_guard()
+ { _M_device.unlock(); }
+
+ lock_guard(const lock_guard&) = delete;
+ lock_guard& operator=(const lock_guard&) = delete;
+
+ private:
+ mutex_type& _M_device;
+ };
+
+ /// unique_lock
+ template<typename _Mutex>
+ class unique_lock
+ {
+ public:
+ typedef _Mutex mutex_type;
+
+ unique_lock() noexcept
+ : _M_device(0), _M_owns(false)
+ { }
+
+ explicit unique_lock(mutex_type& __m)
+ : _M_device(&__m), _M_owns(false)
+ {
+ lock();
+ _M_owns = true;
+ }
+
+ unique_lock(mutex_type& __m, defer_lock_t) noexcept
+ : _M_device(&__m), _M_owns(false)
+ { }
+
+ unique_lock(mutex_type& __m, try_to_lock_t)
+ : _M_device(&__m), _M_owns(_M_device->try_lock())
+ { }
+
+ unique_lock(mutex_type& __m, adopt_lock_t)
+ : _M_device(&__m), _M_owns(true)
+ {
+ // XXX calling thread owns mutex
+ }
+
+ template<typename _Clock, typename _Duration>
+ unique_lock(mutex_type& __m,
+ const chrono::time_point<_Clock, _Duration>& __atime)
+ : _M_device(&__m), _M_owns(_M_device->try_lock_until(__atime))
+ { }
+
+ template<typename _Rep, typename _Period>
+ unique_lock(mutex_type& __m,
+ const chrono::duration<_Rep, _Period>& __rtime)
+ : _M_device(&__m), _M_owns(_M_device->try_lock_for(__rtime))
+ { }
+
+ ~unique_lock()
+ {
+ if (_M_owns)
+ unlock();
+ }
+
+ unique_lock(const unique_lock&) = delete;
+ unique_lock& operator=(const unique_lock&) = delete;
+
+ unique_lock(unique_lock&& __u) noexcept
+ : _M_device(__u._M_device), _M_owns(__u._M_owns)
+ {
+ __u._M_device = 0;
+ __u._M_owns = false;
+ }
+
+ unique_lock& operator=(unique_lock&& __u) noexcept
+ {
+ if(_M_owns)
+ unlock();
+
+ unique_lock(std::move(__u)).swap(*this);
+
+ __u._M_device = 0;
+ __u._M_owns = false;
+
+ return *this;
+ }
+
+ void
+ lock()
+ {
+ if (!_M_device)
+ __throw_system_error(int(errc::operation_not_permitted));
+ else if (_M_owns)
+ __throw_system_error(int(errc::resource_deadlock_would_occur));
+ else
+ {
+ _M_device->lock();
+ _M_owns = true;
+ }
+ }
+
+ bool
+ try_lock()
+ {
+ if (!_M_device)
+ __throw_system_error(int(errc::operation_not_permitted));
+ else if (_M_owns)
+ __throw_system_error(int(errc::resource_deadlock_would_occur));
+ else
+ {
+ _M_owns = _M_device->try_lock();
+ return _M_owns;
+ }
+ }
+
+ template<typename _Clock, typename _Duration>
+ bool
+ try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
+ {
+ if (!_M_device)
+ __throw_system_error(int(errc::operation_not_permitted));
+ else if (_M_owns)
+ __throw_system_error(int(errc::resource_deadlock_would_occur));
+ else
+ {
+ _M_owns = _M_device->try_lock_until(__atime);
+ return _M_owns;
+ }
+ }
+
+ template<typename _Rep, typename _Period>
+ bool
+ try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
+ {
+ if (!_M_device)
+ __throw_system_error(int(errc::operation_not_permitted));
+ else if (_M_owns)
+ __throw_system_error(int(errc::resource_deadlock_would_occur));
+ else
+ {
+ _M_owns = _M_device->try_lock_for(__rtime);
+ return _M_owns;
+ }
+ }
+
+ void
+ unlock()
+ {
+ if (!_M_owns)
+ __throw_system_error(int(errc::operation_not_permitted));
+ else if (_M_device)
+ {
+ _M_device->unlock();
+ _M_owns = false;
+ }
+ }
+
+ void
+ swap(unique_lock& __u) noexcept
+ {
+ std::swap(_M_device, __u._M_device);
+ std::swap(_M_owns, __u._M_owns);
+ }
+
+ mutex_type*
+ release() noexcept
+ {
+ mutex_type* __ret = _M_device;
+ _M_device = 0;
+ _M_owns = false;
+ return __ret;
+ }
+
+ bool
+ owns_lock() const noexcept
+ { return _M_owns; }
+
+ explicit operator bool() const noexcept
+ { return owns_lock(); }
+
+ mutex_type*
+ mutex() const noexcept
+ { return _M_device; }
+
+ private:
+ mutex_type* _M_device;
+ bool _M_owns; // XXX use atomic_bool
+ };
+
+ /// Partial specialization for unique_lock objects.
+ template<typename _Mutex>
+ inline void
+ swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) noexcept
+ { __x.swap(__y); }
+
+ template<int _Idx>
+ struct __unlock_impl
+ {
+ template<typename... _Lock>
+ static void
+ __do_unlock(tuple<_Lock&...>& __locks)
+ {
+ std::get<_Idx>(__locks).unlock();
+ __unlock_impl<_Idx - 1>::__do_unlock(__locks);
+ }
+ };
+
+ template<>
+ struct __unlock_impl<-1>
+ {
+ template<typename... _Lock>
+ static void
+ __do_unlock(tuple<_Lock&...>&)
+ { }
+ };
+
+ template<typename _Lock>
+ unique_lock<_Lock>
+ __try_to_lock(_Lock& __l)
+ { return unique_lock<_Lock>(__l, try_to_lock); }
+
+ template<int _Idx, bool _Continue = true>
+ struct __try_lock_impl
+ {
+ template<typename... _Lock>
+ static void
+ __do_try_lock(tuple<_Lock&...>& __locks, int& __idx)
+ {
+ __idx = _Idx;
+ auto __lock = __try_to_lock(std::get<_Idx>(__locks));
+ if (__lock.owns_lock())
+ {
+ __try_lock_impl<_Idx + 1, _Idx + 2 < sizeof...(_Lock)>::
+ __do_try_lock(__locks, __idx);
+ if (__idx == -1)
+ __lock.release();
+ }
+ }
+ };
+
+ template<int _Idx>
+ struct __try_lock_impl<_Idx, false>
+ {
+ template<typename... _Lock>
+ static void
+ __do_try_lock(tuple<_Lock&...>& __locks, int& __idx)
+ {
+ __idx = _Idx;
+ auto __lock = __try_to_lock(std::get<_Idx>(__locks));
+ if (__lock.owns_lock())
+ {
+ __idx = -1;
+ __lock.release();
+ }
+ }
+ };
+
+ /** @brief Generic try_lock.
+ * @param __l1 Meets Mutex requirements (try_lock() may throw).
+ * @param __l2 Meets Mutex requirements (try_lock() may throw).
+ * @param __l3 Meets Mutex requirements (try_lock() may throw).
+ * @return Returns -1 if all try_lock() calls return true. Otherwise returns
+ * a 0-based index corresponding to the argument that returned false.
+ * @post Either all arguments are locked, or none will be.
+ *
+ * Sequentially calls try_lock() on each argument.
+ */
+ template<typename _Lock1, typename _Lock2, typename... _Lock3>
+ int
+ try_lock(_Lock1& __l1, _Lock2& __l2, _Lock3&... __l3)
+ {
+ int __idx;
+ auto __locks = std::tie(__l1, __l2, __l3...);
+ __try
+ { __try_lock_impl<0>::__do_try_lock(__locks, __idx); }
+ __catch(...)
+ { }
+ return __idx;
+ }
+
+ /** @brief Generic lock.
+ * @param __l1 Meets Mutex requirements (try_lock() may throw).
+ * @param __l2 Meets Mutex requirements (try_lock() may throw).
+ * @param __l3 Meets Mutex requirements (try_lock() may throw).
+ * @throw An exception thrown by an argument's lock() or try_lock() member.
+ * @post All arguments are locked.
+ *
+ * All arguments are locked via a sequence of calls to lock(), try_lock()
+ * and unlock(). If the call exits via an exception any locks that were
+ * obtained will be released.
+ */
+ template<typename _L1, typename _L2, typename ..._L3>
+ void
+ lock(_L1& __l1, _L2& __l2, _L3&... __l3)
+ {
+ while (true)
+ {
+ unique_lock<_L1> __first(__l1);
+ int __idx;
+ auto __locks = std::tie(__l2, __l3...);
+ __try_lock_impl<0, sizeof...(_L3)>::__do_try_lock(__locks, __idx);
+ if (__idx == -1)
+ {
+ __first.release();
+ return;
+ }
+ }
+ }
+
+#ifdef _GLIBCXX_HAS_GTHREADS
+ /// once_flag
+ struct once_flag
+ {
+ private:
+ typedef __gthread_once_t __native_type;
+ __native_type _M_once = __GTHREAD_ONCE_INIT;
+
+ public:
+ /// Constructor
+ constexpr once_flag() noexcept = default;
+
+ /// Deleted copy constructor
+ once_flag(const once_flag&) = delete;
+ /// Deleted assignment operator
+ once_flag& operator=(const once_flag&) = delete;
+
+ template<typename _Callable, typename... _Args>
+ friend void
+ call_once(once_flag& __once, _Callable&& __f, _Args&&... __args);
+ };
+
+#ifdef _GLIBCXX_HAVE_TLS
+ extern __thread void* __once_callable;
+ extern __thread void (*__once_call)();
+
+ template<typename _Callable>
+ inline void
+ __once_call_impl()
+ {
+ (*(_Callable*)__once_callable)();
+ }
+#else
+ extern function<void()> __once_functor;
+
+ extern void
+ __set_once_functor_lock_ptr(unique_lock<mutex>*);
+
+ extern mutex&
+ __get_once_mutex();
+#endif
+
+ extern "C" void __once_proxy(void);
+
+ /// call_once
+ template<typename _Callable, typename... _Args>
+ void
+ call_once(once_flag& __once, _Callable&& __f, _Args&&... __args)
+ {
+#ifdef _GLIBCXX_HAVE_TLS
+ auto __bound_functor = std::__bind_simple(std::forward<_Callable>(__f),
+ std::forward<_Args>(__args)...);
+ __once_callable = &__bound_functor;
+ __once_call = &__once_call_impl<decltype(__bound_functor)>;
+#else
+ unique_lock<mutex> __functor_lock(__get_once_mutex());
+ auto __callable = std::__bind_simple(std::forward<_Callable>(__f),
+ std::forward<_Args>(__args)...);
+ __once_functor = [&]() { __callable(); };
+ __set_once_functor_lock_ptr(&__functor_lock);
+#endif
+
+ int __e = __gthread_once(&__once._M_once, &__once_proxy);
+
+#ifndef _GLIBCXX_HAVE_TLS
+ if (__functor_lock)
+ __set_once_functor_lock_ptr(0);
+#endif
+
+ if (__e)
+ __throw_system_error(__e);
+ }
+#endif // _GLIBCXX_HAS_GTHREADS
+
+ // @} group mutexes
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+#endif // _GLIBCXX_USE_C99_STDINT_TR1
+
+#endif // C++11
+
+#endif // _GLIBCXX_MUTEX
diff --git a/gcc-4.9/libstdc++-v3/include/std/numeric b/gcc-4.9/libstdc++-v3/include/std/numeric
new file mode 100644
index 0000000..8c04376
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/numeric
@@ -0,0 +1,77 @@
+// <numeric> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/numeric
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_NUMERIC
+#define _GLIBCXX_NUMERIC 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <bits/stl_iterator_base_types.h>
+#include <bits/stl_numeric.h>
+
+#ifdef _GLIBCXX_PARALLEL
+# include <parallel/numeric>
+#endif
+
+/**
+ * @defgroup numerics Numerics
+ *
+ * Components for performing numeric operations. Includes support for
+ * for complex number types, random number generation, numeric
+ * (n-at-a-time) arrays, generalized numeric algorithms, and special
+ * math functions.
+ */
+
+#endif /* _GLIBCXX_NUMERIC */
diff --git a/gcc-4.9/libstdc++-v3/include/std/ostream b/gcc-4.9/libstdc++-v3/include/std/ostream
new file mode 100644
index 0000000..18a56ae
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/ostream
@@ -0,0 +1,611 @@
+// Output streams -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/ostream
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 27.6.2 Output streams
+//
+
+#ifndef _GLIBCXX_OSTREAM
+#define _GLIBCXX_OSTREAM 1
+
+#pragma GCC system_header
+
+#include <ios>
+#include <bits/ostream_insert.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @brief Template class basic_ostream.
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ *
+ * This is the base class for all output streams. It provides text
+ * formatting of all builtin types, and communicates with any class
+ * derived from basic_streambuf to do the actual output.
+ */
+ template<typename _CharT, typename _Traits>
+ class basic_ostream : virtual public basic_ios<_CharT, _Traits>
+ {
+ public:
+ // Types (inherited from basic_ios):
+ typedef _CharT char_type;
+ typedef typename _Traits::int_type int_type;
+ typedef typename _Traits::pos_type pos_type;
+ typedef typename _Traits::off_type off_type;
+ typedef _Traits traits_type;
+
+ // Non-standard Types:
+ typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
+ typedef basic_ios<_CharT, _Traits> __ios_type;
+ typedef basic_ostream<_CharT, _Traits> __ostream_type;
+ typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
+ __num_put_type;
+ typedef ctype<_CharT> __ctype_type;
+
+ /**
+ * @brief Base constructor.
+ *
+ * This ctor is almost never called by the user directly, rather from
+ * derived classes' initialization lists, which pass a pointer to
+ * their own stream buffer.
+ */
+ explicit
+ basic_ostream(__streambuf_type* __sb)
+ { this->init(__sb); }
+
+ /**
+ * @brief Base destructor.
+ *
+ * This does very little apart from providing a virtual base dtor.
+ */
+ virtual
+ ~basic_ostream() { }
+
+ /// Safe prefix/suffix operations.
+ class sentry;
+ friend class sentry;
+
+ //@{
+ /**
+ * @brief Interface for manipulators.
+ *
+ * Manipulators such as @c std::endl and @c std::hex use these
+ * functions in constructs like "std::cout << std::endl". For more
+ * information, see the iomanip header.
+ */
+ __ostream_type&
+ operator<<(__ostream_type& (*__pf)(__ostream_type&))
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 60. What is a formatted input function?
+ // The inserters for manipulators are *not* formatted output functions.
+ return __pf(*this);
+ }
+
+ __ostream_type&
+ operator<<(__ios_type& (*__pf)(__ios_type&))
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 60. What is a formatted input function?
+ // The inserters for manipulators are *not* formatted output functions.
+ __pf(*this);
+ return *this;
+ }
+
+ __ostream_type&
+ operator<<(ios_base& (*__pf) (ios_base&))
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // DR 60. What is a formatted input function?
+ // The inserters for manipulators are *not* formatted output functions.
+ __pf(*this);
+ return *this;
+ }
+ //@}
+
+ //@{
+ /**
+ * @name Inserters
+ *
+ * All the @c operator<< functions (aka <em>formatted output
+ * functions</em>) have some common behavior. Each starts by
+ * constructing a temporary object of type std::basic_ostream::sentry.
+ * This can have several effects, concluding with the setting of a
+ * status flag; see the sentry documentation for more.
+ *
+ * If the sentry status is good, the function tries to generate
+ * whatever data is appropriate for the type of the argument.
+ *
+ * If an exception is thrown during insertion, ios_base::badbit
+ * will be turned on in the stream's error state without causing an
+ * ios_base::failure to be thrown. The original exception will then
+ * be rethrown.
+ */
+
+ //@{
+ /**
+ * @brief Integer arithmetic inserters
+ * @param __n A variable of builtin integral type.
+ * @return @c *this if successful
+ *
+ * These functions use the stream's current locale (specifically, the
+ * @c num_get facet) to perform numeric formatting.
+ */
+ __ostream_type&
+ operator<<(long __n)
+ { return _M_insert(__n); }
+
+ __ostream_type&
+ operator<<(unsigned long __n)
+ { return _M_insert(__n); }
+
+ __ostream_type&
+ operator<<(bool __n)
+ { return _M_insert(__n); }
+
+ __ostream_type&
+ operator<<(short __n);
+
+ __ostream_type&
+ operator<<(unsigned short __n)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ return _M_insert(static_cast<unsigned long>(__n));
+ }
+
+ __ostream_type&
+ operator<<(int __n);
+
+ __ostream_type&
+ operator<<(unsigned int __n)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ return _M_insert(static_cast<unsigned long>(__n));
+ }
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ __ostream_type&
+ operator<<(long long __n)
+ { return _M_insert(__n); }
+
+ __ostream_type&
+ operator<<(unsigned long long __n)
+ { return _M_insert(__n); }
+#endif
+ //@}
+
+ //@{
+ /**
+ * @brief Floating point arithmetic inserters
+ * @param __f A variable of builtin floating point type.
+ * @return @c *this if successful
+ *
+ * These functions use the stream's current locale (specifically, the
+ * @c num_get facet) to perform numeric formatting.
+ */
+ __ostream_type&
+ operator<<(double __f)
+ { return _M_insert(__f); }
+
+ __ostream_type&
+ operator<<(float __f)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 117. basic_ostream uses nonexistent num_put member functions.
+ return _M_insert(static_cast<double>(__f));
+ }
+
+ __ostream_type&
+ operator<<(long double __f)
+ { return _M_insert(__f); }
+ //@}
+
+ /**
+ * @brief Pointer arithmetic inserters
+ * @param __p A variable of pointer type.
+ * @return @c *this if successful
+ *
+ * These functions use the stream's current locale (specifically, the
+ * @c num_get facet) to perform numeric formatting.
+ */
+ __ostream_type&
+ operator<<(const void* __p)
+ { return _M_insert(__p); }
+
+ /**
+ * @brief Extracting from another streambuf.
+ * @param __sb A pointer to a streambuf
+ *
+ * This function behaves like one of the basic arithmetic extractors,
+ * in that it also constructs a sentry object and has the same error
+ * handling behavior.
+ *
+ * If @p __sb is NULL, the stream will set failbit in its error state.
+ *
+ * Characters are extracted from @p __sb and inserted into @c *this
+ * until one of the following occurs:
+ *
+ * - the input stream reaches end-of-file,
+ * - insertion into the output sequence fails (in this case, the
+ * character that would have been inserted is not extracted), or
+ * - an exception occurs while getting a character from @p __sb, which
+ * sets failbit in the error state
+ *
+ * If the function inserts no characters, failbit is set.
+ */
+ __ostream_type&
+ operator<<(__streambuf_type* __sb);
+ //@}
+
+ //@{
+ /**
+ * @name Unformatted Output Functions
+ *
+ * All the unformatted output functions have some common behavior.
+ * Each starts by constructing a temporary object of type
+ * std::basic_ostream::sentry. This has several effects, concluding
+ * with the setting of a status flag; see the sentry documentation
+ * for more.
+ *
+ * If the sentry status is good, the function tries to generate
+ * whatever data is appropriate for the type of the argument.
+ *
+ * If an exception is thrown during insertion, ios_base::badbit
+ * will be turned on in the stream's error state. If badbit is on in
+ * the stream's exceptions mask, the exception will be rethrown
+ * without completing its actions.
+ */
+
+ /**
+ * @brief Simple insertion.
+ * @param __c The character to insert.
+ * @return *this
+ *
+ * Tries to insert @p __c.
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
+ __ostream_type&
+ put(char_type __c);
+
+ /**
+ * @brief Core write functionality, without sentry.
+ * @param __s The array to insert.
+ * @param __n Maximum number of characters to insert.
+ */
+ void
+ _M_write(const char_type* __s, streamsize __n)
+ {
+ const streamsize __put = this->rdbuf()->sputn(__s, __n);
+ if (__put != __n)
+ this->setstate(ios_base::badbit);
+ }
+
+ /**
+ * @brief Character string insertion.
+ * @param __s The array to insert.
+ * @param __n Maximum number of characters to insert.
+ * @return *this
+ *
+ * Characters are copied from @p __s and inserted into the stream until
+ * one of the following happens:
+ *
+ * - @p __n characters are inserted
+ * - inserting into the output sequence fails (in this case, badbit
+ * will be set in the stream's error state)
+ *
+ * @note This function is not overloaded on signed char and
+ * unsigned char.
+ */
+ __ostream_type&
+ write(const char_type* __s, streamsize __n);
+ //@}
+
+ /**
+ * @brief Synchronizing the stream buffer.
+ * @return *this
+ *
+ * If @c rdbuf() is a null pointer, changes nothing.
+ *
+ * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
+ * sets badbit.
+ */
+ __ostream_type&
+ flush();
+
+ /**
+ * @brief Getting the current write position.
+ * @return A file position object.
+ *
+ * If @c fail() is not false, returns @c pos_type(-1) to indicate
+ * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,out).
+ */
+ pos_type
+ tellp();
+
+ /**
+ * @brief Changing the current write position.
+ * @param __pos A file position object.
+ * @return *this
+ *
+ * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If
+ * that function fails, sets failbit.
+ */
+ __ostream_type&
+ seekp(pos_type);
+
+ /**
+ * @brief Changing the current write position.
+ * @param __off A file offset object.
+ * @param __dir The direction in which to seek.
+ * @return *this
+ *
+ * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
+ * If that function fails, sets failbit.
+ */
+ __ostream_type&
+ seekp(off_type, ios_base::seekdir);
+
+ protected:
+ basic_ostream()
+ { this->init(0); }
+
+ template<typename _ValueT>
+ __ostream_type&
+ _M_insert(_ValueT __v);
+ };
+
+ /**
+ * @brief Performs setup work for output streams.
+ *
+ * Objects of this class are created before all of the standard
+ * inserters are run. It is responsible for <em>exception-safe prefix and
+ * suffix operations</em>.
+ */
+ template <typename _CharT, typename _Traits>
+ class basic_ostream<_CharT, _Traits>::sentry
+ {
+ // Data Members.
+ bool _M_ok;
+ basic_ostream<_CharT, _Traits>& _M_os;
+
+ public:
+ /**
+ * @brief The constructor performs preparatory work.
+ * @param __os The output stream to guard.
+ *
+ * If the stream state is good (@a __os.good() is true), then if the
+ * stream is tied to another output stream, @c is.tie()->flush()
+ * is called to synchronize the output sequences.
+ *
+ * If the stream state is still good, then the sentry state becomes
+ * true (@a okay).
+ */
+ explicit
+ sentry(basic_ostream<_CharT, _Traits>& __os);
+
+ /**
+ * @brief Possibly flushes the stream.
+ *
+ * If @c ios_base::unitbuf is set in @c os.flags(), and
+ * @c std::uncaught_exception() is true, the sentry destructor calls
+ * @c flush() on the output stream.
+ */
+ ~sentry()
+ {
+ // XXX MT
+ if (bool(_M_os.flags() & ios_base::unitbuf) && !uncaught_exception())
+ {
+ // Can't call flush directly or else will get into recursive lock.
+ if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1)
+ _M_os.setstate(ios_base::badbit);
+ }
+ }
+
+ /**
+ * @brief Quick status checking.
+ * @return The sentry state.
+ *
+ * For ease of use, sentries may be converted to booleans. The
+ * return value is that of the sentry state (true == okay).
+ */
+#if __cplusplus >= 201103L
+ explicit
+#endif
+ operator bool() const
+ { return _M_ok; }
+ };
+
+ //@{
+ /**
+ * @brief Character inserters
+ * @param __out An output stream.
+ * @param __c A character.
+ * @return out
+ *
+ * Behaves like one of the formatted arithmetic inserters described in
+ * std::basic_ostream. After constructing a sentry object with good
+ * status, this function inserts a single character and any required
+ * padding (as determined by [22.2.2.2.2]). @c __out.width(0) is then
+ * called.
+ *
+ * If @p __c is of type @c char and the character type of the stream is not
+ * @c char, the character is widened before insertion.
+ */
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
+ { return __ostream_insert(__out, &__c, 1); }
+
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
+ { return (__out << __out.widen(__c)); }
+
+ // Specialization
+ template <class _Traits>
+ inline basic_ostream<char, _Traits>&
+ operator<<(basic_ostream<char, _Traits>& __out, char __c)
+ { return __ostream_insert(__out, &__c, 1); }
+
+ // Signed and unsigned
+ template<class _Traits>
+ inline basic_ostream<char, _Traits>&
+ operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
+ { return (__out << static_cast<char>(__c)); }
+
+ template<class _Traits>
+ inline basic_ostream<char, _Traits>&
+ operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
+ { return (__out << static_cast<char>(__c)); }
+ //@}
+
+ //@{
+ /**
+ * @brief String inserters
+ * @param __out An output stream.
+ * @param __s A character string.
+ * @return out
+ * @pre @p __s must be a non-NULL pointer
+ *
+ * Behaves like one of the formatted arithmetic inserters described in
+ * std::basic_ostream. After constructing a sentry object with good
+ * status, this function inserts @c traits::length(__s) characters starting
+ * at @p __s, widened if necessary, followed by any required padding (as
+ * determined by [22.2.2.2.2]). @c __out.width(0) is then called.
+ */
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
+ {
+ if (!__s)
+ __out.setstate(ios_base::badbit);
+ else
+ __ostream_insert(__out, __s,
+ static_cast<streamsize>(_Traits::length(__s)));
+ return __out;
+ }
+
+ template<typename _CharT, typename _Traits>
+ basic_ostream<_CharT, _Traits> &
+ operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s);
+
+ // Partial specializations
+ template<class _Traits>
+ inline basic_ostream<char, _Traits>&
+ operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
+ {
+ if (!__s)
+ __out.setstate(ios_base::badbit);
+ else
+ __ostream_insert(__out, __s,
+ static_cast<streamsize>(_Traits::length(__s)));
+ return __out;
+ }
+
+ // Signed and unsigned
+ template<class _Traits>
+ inline basic_ostream<char, _Traits>&
+ operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
+ { return (__out << reinterpret_cast<const char*>(__s)); }
+
+ template<class _Traits>
+ inline basic_ostream<char, _Traits> &
+ operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
+ { return (__out << reinterpret_cast<const char*>(__s)); }
+ //@}
+
+ // Standard basic_ostream manipulators
+
+ /**
+ * @brief Write a newline and flush the stream.
+ *
+ * This manipulator is often mistakenly used when a simple newline is
+ * desired, leading to poor buffering performance. See
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html
+ * for more on this subject.
+ */
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ endl(basic_ostream<_CharT, _Traits>& __os)
+ { return flush(__os.put(__os.widen('\n'))); }
+
+ /**
+ * @brief Write a null character into the output sequence.
+ *
+ * <em>Null character</em> is @c CharT() by definition. For CharT
+ * of @c char, this correctly writes the ASCII @c NUL character
+ * string terminator.
+ */
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ ends(basic_ostream<_CharT, _Traits>& __os)
+ { return __os.put(_CharT()); }
+
+ /**
+ * @brief Flushes the output stream.
+ *
+ * This manipulator simply calls the stream's @c flush() member function.
+ */
+ template<typename _CharT, typename _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ flush(basic_ostream<_CharT, _Traits>& __os)
+ { return __os.flush(); }
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Generic inserter for rvalue stream
+ * @param __os An input stream.
+ * @param __x A reference to the object being inserted.
+ * @return os
+ *
+ * This is just a forwarding function to allow insertion to
+ * rvalue streams since they won't bind to the inserter functions
+ * that take an lvalue reference.
+ */
+ template<typename _CharT, typename _Traits, typename _Tp>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
+ { return (__os << __x); }
+#endif // C++11
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+
+#include <bits/ostream.tcc>
+
+#endif /* _GLIBCXX_OSTREAM */
diff --git a/gcc-4.9/libstdc++-v3/include/std/queue b/gcc-4.9/libstdc++-v3/include/std/queue
new file mode 100644
index 0000000..43a10f9
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/queue
@@ -0,0 +1,66 @@
+// <queue> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/queue
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_QUEUE
+#define _GLIBCXX_QUEUE 1
+
+#pragma GCC system_header
+
+#include <deque>
+#include <vector>
+#include <bits/stl_heap.h>
+#include <bits/stl_function.h>
+#include <bits/stl_queue.h>
+
+#endif /* _GLIBCXX_QUEUE */
diff --git a/gcc-4.9/libstdc++-v3/include/std/random b/gcc-4.9/libstdc++-v3/include/std/random
new file mode 100644
index 0000000..d9d89c3
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/random
@@ -0,0 +1,57 @@
+// <random> -*- C++ -*-
+
+// Copyright (C) 2007-2014 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/random
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_RANDOM
+#define _GLIBCXX_RANDOM 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <cmath>
+#include <cstdlib>
+#include <string>
+#include <iosfwd>
+#include <limits>
+#include <debug/debug.h>
+#include <type_traits>
+
+#ifdef _GLIBCXX_USE_C99_STDINT_TR1
+
+#include <cstdint> // For uint_fast32_t, uint_fast64_t, uint_least32_t
+#include <bits/random.h>
+#include <bits/opt_random.h>
+#include <bits/random.tcc>
+
+#endif // _GLIBCXX_USE_C99_STDINT_TR1
+
+#endif // C++11
+
+#endif // _GLIBCXX_RANDOM
diff --git a/gcc-4.9/libstdc++-v3/include/std/ratio b/gcc-4.9/libstdc++-v3/include/std/ratio
new file mode 100644
index 0000000..624e198
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/ratio
@@ -0,0 +1,538 @@
+// ratio -*- C++ -*-
+
+// Copyright (C) 2008-2014 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/ratio
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_RATIO
+#define _GLIBCXX_RATIO 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <type_traits>
+#include <cstdint>
+
+#ifdef _GLIBCXX_USE_C99_STDINT_TR1
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @defgroup ratio Rational Arithmetic
+ * @ingroup utilities
+ *
+ * Compile time representation of finite rational numbers.
+ * @{
+ */
+
+ template<intmax_t _Pn>
+ struct __static_sign
+ : integral_constant<intmax_t, (_Pn < 0) ? -1 : 1>
+ { };
+
+ template<intmax_t _Pn>
+ struct __static_abs
+ : integral_constant<intmax_t, _Pn * __static_sign<_Pn>::value>
+ { };
+
+ template<intmax_t _Pn, intmax_t _Qn>
+ struct __static_gcd
+ : __static_gcd<_Qn, (_Pn % _Qn)>
+ { };
+
+ template<intmax_t _Pn>
+ struct __static_gcd<_Pn, 0>
+ : integral_constant<intmax_t, __static_abs<_Pn>::value>
+ { };
+
+ template<intmax_t _Qn>
+ struct __static_gcd<0, _Qn>
+ : integral_constant<intmax_t, __static_abs<_Qn>::value>
+ { };
+
+ // Let c = 2^(half # of bits in an intmax_t)
+ // then we find a1, a0, b1, b0 s.t. N = a1*c + a0, M = b1*c + b0
+ // The multiplication of N and M becomes,
+ // N * M = (a1 * b1)c^2 + (a0 * b1 + b0 * a1)c + a0 * b0
+ // Multiplication is safe if each term and the sum of the terms
+ // is representable by intmax_t.
+ template<intmax_t _Pn, intmax_t _Qn>
+ struct __safe_multiply
+ {
+ private:
+ static const uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4);
+
+ static const uintmax_t __a0 = __static_abs<_Pn>::value % __c;
+ static const uintmax_t __a1 = __static_abs<_Pn>::value / __c;
+ static const uintmax_t __b0 = __static_abs<_Qn>::value % __c;
+ static const uintmax_t __b1 = __static_abs<_Qn>::value / __c;
+
+ static_assert(__a1 == 0 || __b1 == 0,
+ "overflow in multiplication");
+ static_assert(__a0 * __b1 + __b0 * __a1 < (__c >> 1),
+ "overflow in multiplication");
+ static_assert(__b0 * __a0 <= __INTMAX_MAX__,
+ "overflow in multiplication");
+ static_assert((__a0 * __b1 + __b0 * __a1) * __c
+ <= __INTMAX_MAX__ - __b0 * __a0,
+ "overflow in multiplication");
+
+ public:
+ static const intmax_t value = _Pn * _Qn;
+ };
+
+ // Some double-precision utilities, where numbers are represented as
+ // __hi*2^(8*sizeof(uintmax_t)) + __lo.
+ template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2>
+ struct __big_less
+ : integral_constant<bool, (__hi1 < __hi2
+ || (__hi1 == __hi2 && __lo1 < __lo2))>
+ { };
+
+ template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2>
+ struct __big_add
+ {
+ static constexpr uintmax_t __lo = __lo1 + __lo2;
+ static constexpr uintmax_t __hi = (__hi1 + __hi2 +
+ (__lo1 + __lo2 < __lo1)); // carry
+ };
+
+ // Subtract a number from a bigger one.
+ template<uintmax_t __hi1, uintmax_t __lo1, uintmax_t __hi2, uintmax_t __lo2>
+ struct __big_sub
+ {
+ static_assert(!__big_less<__hi1, __lo1, __hi2, __lo2>::value,
+ "Internal library error");
+ static constexpr uintmax_t __lo = __lo1 - __lo2;
+ static constexpr uintmax_t __hi = (__hi1 - __hi2 -
+ (__lo1 < __lo2)); // carry
+ };
+
+ // Same principle as __safe_multiply.
+ template<uintmax_t __x, uintmax_t __y>
+ struct __big_mul
+ {
+ private:
+ static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4);
+ static constexpr uintmax_t __x0 = __x % __c;
+ static constexpr uintmax_t __x1 = __x / __c;
+ static constexpr uintmax_t __y0 = __y % __c;
+ static constexpr uintmax_t __y1 = __y / __c;
+ static constexpr uintmax_t __x0y0 = __x0 * __y0;
+ static constexpr uintmax_t __x0y1 = __x0 * __y1;
+ static constexpr uintmax_t __x1y0 = __x1 * __y0;
+ static constexpr uintmax_t __x1y1 = __x1 * __y1;
+ static constexpr uintmax_t __mix = __x0y1 + __x1y0; // possible carry...
+ static constexpr uintmax_t __mix_lo = __mix * __c;
+ static constexpr uintmax_t __mix_hi
+ = __mix / __c + ((__mix < __x0y1) ? __c : 0); // ... added here
+ typedef __big_add<__mix_hi, __mix_lo, __x1y1, __x0y0> _Res;
+ public:
+ static constexpr uintmax_t __hi = _Res::__hi;
+ static constexpr uintmax_t __lo = _Res::__lo;
+ };
+
+ // Adapted from __udiv_qrnnd_c in longlong.h
+ // This version assumes that the high bit of __d is 1.
+ template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d>
+ struct __big_div_impl
+ {
+ private:
+ static_assert(__d >= (uintmax_t(1) << (sizeof(intmax_t) * 8 - 1)),
+ "Internal library error");
+ static_assert(__n1 < __d, "Internal library error");
+ static constexpr uintmax_t __c = uintmax_t(1) << (sizeof(intmax_t) * 4);
+ static constexpr uintmax_t __d1 = __d / __c;
+ static constexpr uintmax_t __d0 = __d % __c;
+
+ static constexpr uintmax_t __q1x = __n1 / __d1;
+ static constexpr uintmax_t __r1x = __n1 % __d1;
+ static constexpr uintmax_t __m = __q1x * __d0;
+ static constexpr uintmax_t __r1y = __r1x * __c + __n0 / __c;
+ static constexpr uintmax_t __r1z = __r1y + __d;
+ static constexpr uintmax_t __r1
+ = ((__r1y < __m) ? ((__r1z >= __d) && (__r1z < __m))
+ ? (__r1z + __d) : __r1z : __r1y) - __m;
+ static constexpr uintmax_t __q1
+ = __q1x - ((__r1y < __m)
+ ? ((__r1z >= __d) && (__r1z < __m)) ? 2 : 1 : 0);
+ static constexpr uintmax_t __q0x = __r1 / __d1;
+ static constexpr uintmax_t __r0x = __r1 % __d1;
+ static constexpr uintmax_t __n = __q0x * __d0;
+ static constexpr uintmax_t __r0y = __r0x * __c + __n0 % __c;
+ static constexpr uintmax_t __r0z = __r0y + __d;
+ static constexpr uintmax_t __r0
+ = ((__r0y < __n) ? ((__r0z >= __d) && (__r0z < __n))
+ ? (__r0z + __d) : __r0z : __r0y) - __n;
+ static constexpr uintmax_t __q0
+ = __q0x - ((__r0y < __n) ? ((__r0z >= __d)
+ && (__r0z < __n)) ? 2 : 1 : 0);
+
+ public:
+ static constexpr uintmax_t __quot = __q1 * __c + __q0;
+ static constexpr uintmax_t __rem = __r0;
+
+ private:
+ typedef __big_mul<__quot, __d> _Prod;
+ typedef __big_add<_Prod::__hi, _Prod::__lo, 0, __rem> _Sum;
+ static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0,
+ "Internal library error");
+ };
+
+ template<uintmax_t __n1, uintmax_t __n0, uintmax_t __d>
+ struct __big_div
+ {
+ private:
+ static_assert(__d != 0, "Internal library error");
+ static_assert(sizeof (uintmax_t) == sizeof (unsigned long long),
+ "This library calls __builtin_clzll on uintmax_t, which "
+ "is unsafe on your platform. Please complain to "
+ "http://gcc.gnu.org/bugzilla/");
+ static constexpr int __shift = __builtin_clzll(__d);
+ static constexpr int __coshift_ = sizeof(uintmax_t) * 8 - __shift;
+ static constexpr int __coshift = (__shift != 0) ? __coshift_ : 0;
+ static constexpr uintmax_t __c1 = uintmax_t(1) << __shift;
+ static constexpr uintmax_t __c2 = uintmax_t(1) << __coshift;
+ static constexpr uintmax_t __new_d = __d * __c1;
+ static constexpr uintmax_t __new_n0 = __n0 * __c1;
+ static constexpr uintmax_t __n1_shifted = (__n1 % __d) * __c1;
+ static constexpr uintmax_t __n0_top = (__shift != 0) ? (__n0 / __c2) : 0;
+ static constexpr uintmax_t __new_n1 = __n1_shifted + __n0_top;
+ typedef __big_div_impl<__new_n1, __new_n0, __new_d> _Res;
+
+ public:
+ static constexpr uintmax_t __quot_hi = __n1 / __d;
+ static constexpr uintmax_t __quot_lo = _Res::__quot;
+ static constexpr uintmax_t __rem = _Res::__rem / __c1;
+
+ private:
+ typedef __big_mul<__quot_lo, __d> _P0;
+ typedef __big_mul<__quot_hi, __d> _P1;
+ typedef __big_add<_P0::__hi, _P0::__lo, _P1::__lo, __rem> _Sum;
+ // No overflow.
+ static_assert(_P1::__hi == 0, "Internal library error");
+ static_assert(_Sum::__hi >= _P0::__hi, "Internal library error");
+ // Matches the input data.
+ static_assert(_Sum::__hi == __n1 && _Sum::__lo == __n0,
+ "Internal library error");
+ static_assert(__rem < __d, "Internal library error");
+ };
+
+ /**
+ * @brief Provides compile-time rational arithmetic.
+ *
+ * This class template represents any finite rational number with a
+ * numerator and denominator representable by compile-time constants of
+ * type intmax_t. The ratio is simplified when instantiated.
+ *
+ * For example:
+ * @code
+ * std::ratio<7,-21>::num == -1;
+ * std::ratio<7,-21>::den == 3;
+ * @endcode
+ *
+ */
+ template<intmax_t _Num, intmax_t _Den = 1>
+ struct ratio
+ {
+ static_assert(_Den != 0, "denominator cannot be zero");
+ static_assert(_Num >= -__INTMAX_MAX__ && _Den >= -__INTMAX_MAX__,
+ "out of range");
+
+ // Note: sign(N) * abs(N) == N
+ static constexpr intmax_t num =
+ _Num * __static_sign<_Den>::value / __static_gcd<_Num, _Den>::value;
+
+ static constexpr intmax_t den =
+ __static_abs<_Den>::value / __static_gcd<_Num, _Den>::value;
+
+ typedef ratio<num, den> type;
+ };
+
+ template<intmax_t _Num, intmax_t _Den>
+ constexpr intmax_t ratio<_Num, _Den>::num;
+
+ template<intmax_t _Num, intmax_t _Den>
+ constexpr intmax_t ratio<_Num, _Den>::den;
+
+ template<typename _R1, typename _R2>
+ struct __ratio_multiply
+ {
+ private:
+ static const intmax_t __gcd1 =
+ __static_gcd<_R1::num, _R2::den>::value;
+ static const intmax_t __gcd2 =
+ __static_gcd<_R2::num, _R1::den>::value;
+
+ public:
+ typedef ratio<
+ __safe_multiply<(_R1::num / __gcd1),
+ (_R2::num / __gcd2)>::value,
+ __safe_multiply<(_R1::den / __gcd2),
+ (_R2::den / __gcd1)>::value> type;
+
+ static constexpr intmax_t num = type::num;
+ static constexpr intmax_t den = type::den;
+ };
+
+ template<typename _R1, typename _R2>
+ constexpr intmax_t __ratio_multiply<_R1, _R2>::num;
+
+ template<typename _R1, typename _R2>
+ constexpr intmax_t __ratio_multiply<_R1, _R2>::den;
+
+ /// ratio_multiply
+ template<typename _R1, typename _R2>
+ using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type;
+
+ template<typename _R1, typename _R2>
+ struct __ratio_divide
+ {
+ static_assert(_R2::num != 0, "division by 0");
+
+ typedef typename __ratio_multiply<
+ _R1,
+ ratio<_R2::den, _R2::num>>::type type;
+
+ static constexpr intmax_t num = type::num;
+ static constexpr intmax_t den = type::den;
+ };
+
+ template<typename _R1, typename _R2>
+ constexpr intmax_t __ratio_divide<_R1, _R2>::num;
+
+ template<typename _R1, typename _R2>
+ constexpr intmax_t __ratio_divide<_R1, _R2>::den;
+
+ /// ratio_divide
+ template<typename _R1, typename _R2>
+ using ratio_divide = typename __ratio_divide<_R1, _R2>::type;
+
+ /// ratio_equal
+ template<typename _R1, typename _R2>
+ struct ratio_equal
+ : integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den>
+ { };
+
+ /// ratio_not_equal
+ template<typename _R1, typename _R2>
+ struct ratio_not_equal
+ : integral_constant<bool, !ratio_equal<_R1, _R2>::value>
+ { };
+
+ // Both numbers are positive.
+ template<typename _R1, typename _R2,
+ typename _Left = __big_mul<_R1::num,_R2::den>,
+ typename _Right = __big_mul<_R2::num,_R1::den> >
+ struct __ratio_less_impl_1
+ : integral_constant<bool, __big_less<_Left::__hi, _Left::__lo,
+ _Right::__hi, _Right::__lo>::value>
+ { };
+
+ template<typename _R1, typename _R2,
+ bool = (_R1::num == 0 || _R2::num == 0
+ || (__static_sign<_R1::num>::value
+ != __static_sign<_R2::num>::value)),
+ bool = (__static_sign<_R1::num>::value == -1
+ && __static_sign<_R2::num>::value == -1)>
+ struct __ratio_less_impl
+ : __ratio_less_impl_1<_R1, _R2>::type
+ { };
+
+ template<typename _R1, typename _R2>
+ struct __ratio_less_impl<_R1, _R2, true, false>
+ : integral_constant<bool, _R1::num < _R2::num>
+ { };
+
+ template<typename _R1, typename _R2>
+ struct __ratio_less_impl<_R1, _R2, false, true>
+ : __ratio_less_impl_1<ratio<-_R2::num, _R2::den>,
+ ratio<-_R1::num, _R1::den> >::type
+ { };
+
+ /// ratio_less
+ template<typename _R1, typename _R2>
+ struct ratio_less
+ : __ratio_less_impl<_R1, _R2>::type
+ { };
+
+ /// ratio_less_equal
+ template<typename _R1, typename _R2>
+ struct ratio_less_equal
+ : integral_constant<bool, !ratio_less<_R2, _R1>::value>
+ { };
+
+ /// ratio_greater
+ template<typename _R1, typename _R2>
+ struct ratio_greater
+ : integral_constant<bool, ratio_less<_R2, _R1>::value>
+ { };
+
+ /// ratio_greater_equal
+ template<typename _R1, typename _R2>
+ struct ratio_greater_equal
+ : integral_constant<bool, !ratio_less<_R1, _R2>::value>
+ { };
+
+ template<typename _R1, typename _R2,
+ bool = (_R1::num >= 0),
+ bool = (_R2::num >= 0),
+ bool = ratio_less<ratio<__static_abs<_R1::num>::value, _R1::den>,
+ ratio<__static_abs<_R2::num>::value, _R2::den> >::value>
+ struct __ratio_add_impl
+ {
+ private:
+ typedef typename __ratio_add_impl<
+ ratio<-_R1::num, _R1::den>,
+ ratio<-_R2::num, _R2::den> >::type __t;
+ public:
+ typedef ratio<-__t::num, __t::den> type;
+ };
+
+ // True addition of nonnegative numbers.
+ template<typename _R1, typename _R2, bool __b>
+ struct __ratio_add_impl<_R1, _R2, true, true, __b>
+ {
+ private:
+ static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value;
+ static constexpr uintmax_t __d2 = _R2::den / __g;
+ typedef __big_mul<_R1::den, __d2> __d;
+ typedef __big_mul<_R1::num, _R2::den / __g> __x;
+ typedef __big_mul<_R2::num, _R1::den / __g> __y;
+ typedef __big_add<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n;
+ static_assert(__n::__hi >= __x::__hi, "Internal library error");
+ typedef __big_div<__n::__hi, __n::__lo, __g> __ng;
+ static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value;
+ typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final;
+ static_assert(__n_final::__rem == 0, "Internal library error");
+ static_assert(__n_final::__quot_hi == 0 &&
+ __n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition");
+ typedef __big_mul<_R1::den / __g2, __d2> __d_final;
+ static_assert(__d_final::__hi == 0 &&
+ __d_final::__lo <= __INTMAX_MAX__, "overflow in addition");
+ public:
+ typedef ratio<__n_final::__quot_lo, __d_final::__lo> type;
+ };
+
+ template<typename _R1, typename _R2>
+ struct __ratio_add_impl<_R1, _R2, false, true, true>
+ : __ratio_add_impl<_R2, _R1>
+ { };
+
+ // True subtraction of nonnegative numbers yielding a nonnegative result.
+ template<typename _R1, typename _R2>
+ struct __ratio_add_impl<_R1, _R2, true, false, false>
+ {
+ private:
+ static constexpr uintmax_t __g = __static_gcd<_R1::den, _R2::den>::value;
+ static constexpr uintmax_t __d2 = _R2::den / __g;
+ typedef __big_mul<_R1::den, __d2> __d;
+ typedef __big_mul<_R1::num, _R2::den / __g> __x;
+ typedef __big_mul<-_R2::num, _R1::den / __g> __y;
+ typedef __big_sub<__x::__hi, __x::__lo, __y::__hi, __y::__lo> __n;
+ typedef __big_div<__n::__hi, __n::__lo, __g> __ng;
+ static constexpr uintmax_t __g2 = __static_gcd<__ng::__rem, __g>::value;
+ typedef __big_div<__n::__hi, __n::__lo, __g2> __n_final;
+ static_assert(__n_final::__rem == 0, "Internal library error");
+ static_assert(__n_final::__quot_hi == 0 &&
+ __n_final::__quot_lo <= __INTMAX_MAX__, "overflow in addition");
+ typedef __big_mul<_R1::den / __g2, __d2> __d_final;
+ static_assert(__d_final::__hi == 0 &&
+ __d_final::__lo <= __INTMAX_MAX__, "overflow in addition");
+ public:
+ typedef ratio<__n_final::__quot_lo, __d_final::__lo> type;
+ };
+
+ template<typename _R1, typename _R2>
+ struct __ratio_add
+ {
+ typedef typename __ratio_add_impl<_R1, _R2>::type type;
+ static constexpr intmax_t num = type::num;
+ static constexpr intmax_t den = type::den;
+ };
+
+ template<typename _R1, typename _R2>
+ constexpr intmax_t __ratio_add<_R1, _R2>::num;
+
+ template<typename _R1, typename _R2>
+ constexpr intmax_t __ratio_add<_R1, _R2>::den;
+
+ /// ratio_add
+ template<typename _R1, typename _R2>
+ using ratio_add = typename __ratio_add<_R1, _R2>::type;
+
+ template<typename _R1, typename _R2>
+ struct __ratio_subtract
+ {
+ typedef typename __ratio_add<
+ _R1,
+ ratio<-_R2::num, _R2::den>>::type type;
+
+ static constexpr intmax_t num = type::num;
+ static constexpr intmax_t den = type::den;
+ };
+
+ template<typename _R1, typename _R2>
+ constexpr intmax_t __ratio_subtract<_R1, _R2>::num;
+
+ template<typename _R1, typename _R2>
+ constexpr intmax_t __ratio_subtract<_R1, _R2>::den;
+
+ /// ratio_subtract
+ template<typename _R1, typename _R2>
+ using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type;
+
+
+ typedef ratio<1, 1000000000000000000> atto;
+ typedef ratio<1, 1000000000000000> femto;
+ typedef ratio<1, 1000000000000> pico;
+ typedef ratio<1, 1000000000> nano;
+ typedef ratio<1, 1000000> micro;
+ typedef ratio<1, 1000> milli;
+ typedef ratio<1, 100> centi;
+ typedef ratio<1, 10> deci;
+ typedef ratio< 10, 1> deca;
+ typedef ratio< 100, 1> hecto;
+ typedef ratio< 1000, 1> kilo;
+ typedef ratio< 1000000, 1> mega;
+ typedef ratio< 1000000000, 1> giga;
+ typedef ratio< 1000000000000, 1> tera;
+ typedef ratio< 1000000000000000, 1> peta;
+ typedef ratio< 1000000000000000000, 1> exa;
+
+ // @} group ratio
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif //_GLIBCXX_USE_C99_STDINT_TR1
+
+#endif // C++11
+
+#endif //_GLIBCXX_RATIO
diff --git a/gcc-4.9/libstdc++-v3/include/std/regex b/gcc-4.9/libstdc++-v3/include/std/regex
new file mode 100644
index 0000000..9161f48
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/regex
@@ -0,0 +1,65 @@
+// <regex> -*- C++ -*-
+
+// Copyright (C) 2007-2014 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/regex
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_REGEX
+#define _GLIBCXX_REGEX 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <algorithm>
+#include <bitset>
+#include <functional>
+#ifdef _GLIBCXX_DEBUG
+# include <iosfwd>
+#endif
+#include <iterator>
+#include <locale>
+#include <memory>
+#include <sstream>
+#include <stack>
+#include <stdexcept>
+#include <string>
+#include <utility>
+#include <vector>
+#include <cstring>
+
+#include <bits/regex_constants.h>
+#include <bits/regex_error.h>
+#include <bits/regex_automaton.h>
+#include <bits/regex.h>
+#include <bits/regex_scanner.h>
+#include <bits/regex_compiler.h>
+#include <bits/regex_executor.h>
+
+#endif // C++11
+
+#endif // _GLIBCXX_REGEX
diff --git a/gcc-4.9/libstdc++-v3/include/std/scoped_allocator b/gcc-4.9/libstdc++-v3/include/std/scoped_allocator
new file mode 100644
index 0000000..33d8779
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/scoped_allocator
@@ -0,0 +1,463 @@
+// <scoped_allocator> -*- C++ -*-
+
+// Copyright (C) 2011-2014 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;
+
+ 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;
+
+ 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))
+ { }
+
+ 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
diff --git a/gcc-4.9/libstdc++-v3/include/std/set b/gcc-4.9/libstdc++-v3/include/std/set
new file mode 100644
index 0000000..cbb17f3
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/set
@@ -0,0 +1,73 @@
+// <set> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/set
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_SET
+#define _GLIBCXX_SET 1
+
+#pragma GCC system_header
+
+#include <bits/stl_tree.h>
+#include <bits/stl_set.h>
+#include <bits/stl_multiset.h>
+#include <bits/range_access.h>
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/set>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/set>
+#endif
+
+#endif /* _GLIBCXX_SET */
diff --git a/gcc-4.9/libstdc++-v3/include/std/shared_mutex b/gcc-4.9/libstdc++-v3/include/std/shared_mutex
new file mode 100644
index 0000000..53b39f8
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/shared_mutex
@@ -0,0 +1,399 @@
+// <shared_mutex> -*- C++ -*-
+
+// Copyright (C) 2013-2014 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/shared_mutex
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_SHARED_MUTEX
+#define _GLIBCXX_SHARED_MUTEX 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include <bits/c++14_warning.h>
+#else
+
+#include <bits/c++config.h>
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+# include <mutex>
+# include <condition_variable>
+#endif
+#include <bits/functexcept.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @ingroup mutexes
+ * @{
+ */
+
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+ /// shared_timed_mutex
+ class shared_timed_mutex
+ {
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+ struct _Mutex : mutex, __timed_mutex_impl<_Mutex>
+ {
+ template<typename _Rep, typename _Period>
+ bool
+ try_lock_for(const chrono::duration<_Rep, _Period>& __rtime)
+ { return _M_try_lock_for(__rtime); }
+
+ template<typename _Clock, typename _Duration>
+ bool
+ try_lock_until(const chrono::time_point<_Clock, _Duration>& __atime)
+ { return _M_try_lock_until(__atime); }
+ };
+#else
+ typedef mutex _Mutex;
+#endif
+
+ // Based on Howard Hinnant's reference implementation from N2406
+
+ _Mutex _M_mut;
+ condition_variable _M_gate1;
+ condition_variable _M_gate2;
+ unsigned _M_state;
+
+ static constexpr unsigned _S_write_entered
+ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1);
+ static constexpr unsigned _M_n_readers = ~_S_write_entered;
+
+ public:
+ shared_timed_mutex() : _M_state(0) {}
+
+ ~shared_timed_mutex()
+ {
+ _GLIBCXX_DEBUG_ASSERT( _M_state == 0 );
+ }
+
+ shared_timed_mutex(const shared_timed_mutex&) = delete;
+ shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
+
+ // Exclusive ownership
+
+ void
+ lock()
+ {
+ unique_lock<mutex> __lk(_M_mut);
+ while (_M_state & _S_write_entered)
+ _M_gate1.wait(__lk);
+ _M_state |= _S_write_entered;
+ while (_M_state & _M_n_readers)
+ _M_gate2.wait(__lk);
+ }
+
+ bool
+ try_lock()
+ {
+ unique_lock<mutex> __lk(_M_mut, try_to_lock);
+ if (__lk.owns_lock() && _M_state == 0)
+ {
+ _M_state = _S_write_entered;
+ return true;
+ }
+ return false;
+ }
+
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+ template<typename _Rep, typename _Period>
+ bool
+ try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time)
+ {
+ unique_lock<_Mutex> __lk(_M_mut, __rel_time);
+ if (__lk.owns_lock() && _M_state == 0)
+ {
+ _M_state = _S_write_entered;
+ return true;
+ }
+ return false;
+ }
+
+ template<typename _Clock, typename _Duration>
+ bool
+ try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time)
+ {
+ unique_lock<_Mutex> __lk(_M_mut, __abs_time);
+ if (__lk.owns_lock() && _M_state == 0)
+ {
+ _M_state = _S_write_entered;
+ return true;
+ }
+ return false;
+ }
+#endif
+
+ void
+ unlock()
+ {
+ {
+ lock_guard<_Mutex> __lk(_M_mut);
+ _M_state = 0;
+ }
+ _M_gate1.notify_all();
+ }
+
+ // Shared ownership
+
+ void
+ lock_shared()
+ {
+ unique_lock<mutex> __lk(_M_mut);
+ while ((_M_state & _S_write_entered)
+ || (_M_state & _M_n_readers) == _M_n_readers)
+ {
+ _M_gate1.wait(__lk);
+ }
+ unsigned __num_readers = (_M_state & _M_n_readers) + 1;
+ _M_state &= ~_M_n_readers;
+ _M_state |= __num_readers;
+ }
+
+ bool
+ try_lock_shared()
+ {
+ unique_lock<_Mutex> __lk(_M_mut, try_to_lock);
+ unsigned __num_readers = _M_state & _M_n_readers;
+ if (__lk.owns_lock() && !(_M_state & _S_write_entered)
+ && __num_readers != _M_n_readers)
+ {
+ ++__num_readers;
+ _M_state &= ~_M_n_readers;
+ _M_state |= __num_readers;
+ return true;
+ }
+ return false;
+ }
+
+#if _GTHREAD_USE_MUTEX_TIMEDLOCK
+ template<typename _Rep, typename _Period>
+ bool
+ try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time)
+ {
+ unique_lock<_Mutex> __lk(_M_mut, __rel_time);
+ if (__lk.owns_lock())
+ {
+ unsigned __num_readers = _M_state & _M_n_readers;
+ if (!(_M_state & _S_write_entered)
+ && __num_readers != _M_n_readers)
+ {
+ ++__num_readers;
+ _M_state &= ~_M_n_readers;
+ _M_state |= __num_readers;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ template <typename _Clock, typename _Duration>
+ bool
+ try_lock_shared_until(const chrono::time_point<_Clock,
+ _Duration>& __abs_time)
+ {
+ unique_lock<_Mutex> __lk(_M_mut, __abs_time);
+ if (__lk.owns_lock())
+ {
+ unsigned __num_readers = _M_state & _M_n_readers;
+ if (!(_M_state & _S_write_entered)
+ && __num_readers != _M_n_readers)
+ {
+ ++__num_readers;
+ _M_state &= ~_M_n_readers;
+ _M_state |= __num_readers;
+ return true;
+ }
+ }
+ return false;
+ }
+#endif
+
+ void
+ unlock_shared()
+ {
+ lock_guard<_Mutex> __lk(_M_mut);
+ unsigned __num_readers = (_M_state & _M_n_readers) - 1;
+ _M_state &= ~_M_n_readers;
+ _M_state |= __num_readers;
+ if (_M_state & _S_write_entered)
+ {
+ if (__num_readers == 0)
+ _M_gate2.notify_one();
+ }
+ else
+ {
+ if (__num_readers == _M_n_readers - 1)
+ _M_gate1.notify_one();
+ }
+ }
+ };
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
+
+ /// shared_lock
+ template<typename _Mutex>
+ class shared_lock
+ {
+ public:
+ typedef _Mutex mutex_type;
+
+ // Shared locking
+
+ shared_lock() noexcept : _M_pm(nullptr), _M_owns(false) { }
+
+ explicit
+ shared_lock(mutex_type& __m) : _M_pm(&__m), _M_owns(true)
+ { __m.lock_shared(); }
+
+ shared_lock(mutex_type& __m, defer_lock_t) noexcept
+ : _M_pm(&__m), _M_owns(false) { }
+
+ shared_lock(mutex_type& __m, try_to_lock_t)
+ : _M_pm(&__m), _M_owns(__m.try_lock_shared()) { }
+
+ shared_lock(mutex_type& __m, adopt_lock_t)
+ : _M_pm(&__m), _M_owns(true) { }
+
+ template<typename _Clock, typename _Duration>
+ shared_lock(mutex_type& __m,
+ const chrono::time_point<_Clock, _Duration>& __abs_time)
+ : _M_pm(&__m), _M_owns(__m.try_lock_shared_until(__abs_time)) { }
+
+ template<typename _Rep, typename _Period>
+ shared_lock(mutex_type& __m,
+ const chrono::duration<_Rep, _Period>& __rel_time)
+ : _M_pm(&__m), _M_owns(__m.try_lock_shared_for(__rel_time)) { }
+
+ ~shared_lock()
+ {
+ if (_M_owns)
+ _M_pm->unlock_shared();
+ }
+
+ shared_lock(shared_lock const&) = delete;
+ shared_lock& operator=(shared_lock const&) = delete;
+
+ shared_lock(shared_lock&& __sl) noexcept : shared_lock()
+ { swap(__sl); }
+
+ shared_lock&
+ operator=(shared_lock&& __sl) noexcept
+ {
+ shared_lock(std::move(__sl)).swap(*this);
+ return *this;
+ }
+
+ void
+ lock()
+ {
+ _M_lockable();
+ _M_pm->lock_shared();
+ _M_owns = true;
+ }
+
+ bool
+ try_lock()
+ {
+ _M_lockable();
+ return _M_owns = _M_pm->try_lock_shared();
+ }
+
+ template<typename _Rep, typename _Period>
+ bool
+ try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time)
+ {
+ _M_lockable();
+ return _M_owns = _M_pm->try_lock_shared_for(__rel_time);
+ }
+
+ template<typename _Clock, typename _Duration>
+ bool
+ try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time)
+ {
+ _M_lockable();
+ return _M_owns = _M_pm->try_lock_shared_until(__abs_time);
+ }
+
+ void
+ unlock()
+ {
+ if (!_M_owns)
+ __throw_system_error(int(errc::resource_deadlock_would_occur));
+ _M_pm->unlock_shared();
+ _M_owns = false;
+ }
+
+ // Setters
+
+ void
+ swap(shared_lock& __u) noexcept
+ {
+ std::swap(_M_pm, __u._M_pm);
+ std::swap(_M_owns, __u._M_owns);
+ }
+
+ mutex_type*
+ release() noexcept
+ {
+ _M_owns = false;
+ return std::exchange(_M_pm, nullptr);
+ }
+
+ // Getters
+
+ bool owns_lock() const noexcept { return _M_owns; }
+
+ explicit operator bool() const noexcept { return _M_owns; }
+
+ mutex_type* mutex() const noexcept { return _M_pm; }
+
+ private:
+ void
+ _M_lockable() const
+ {
+ if (_M_pm == nullptr)
+ __throw_system_error(int(errc::operation_not_permitted));
+ if (_M_owns)
+ __throw_system_error(int(errc::resource_deadlock_would_occur));
+ }
+
+ mutex_type* _M_pm;
+ bool _M_owns;
+ };
+
+ /// Swap specialization for shared_lock
+ template<typename _Mutex>
+ void
+ swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept
+ { __x.swap(__y); }
+
+ // @} group mutexes
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif // C++14
+
+#endif // _GLIBCXX_SHARED_MUTEX
diff --git a/gcc-4.9/libstdc++-v3/include/std/sstream b/gcc-4.9/libstdc++-v3/include/std/sstream
new file mode 100644
index 0000000..74ce16c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/sstream
@@ -0,0 +1,602 @@
+// String based streams -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/sstream
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 27.7 String-based streams
+//
+
+#ifndef _GLIBCXX_SSTREAM
+#define _GLIBCXX_SSTREAM 1
+
+#pragma GCC system_header
+
+#include <istream>
+#include <ostream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // [27.7.1] template class basic_stringbuf
+ /**
+ * @brief The actual work of input and output (for std::string).
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ * @tparam _Alloc Allocator type, defaults to allocator<_CharT>.
+ *
+ * This class associates either or both of its input and output sequences
+ * with a sequence of characters, which can be initialized from, or made
+ * available as, a @c std::basic_string. (Paraphrased from [27.7.1]/1.)
+ *
+ * For this class, open modes (of type @c ios_base::openmode) have
+ * @c in set if the input sequence can be read, and @c out set if the
+ * output sequence can be written.
+ */
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 251. basic_stringbuf missing allocator_type
+ typedef _Alloc allocator_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ typedef basic_streambuf<char_type, traits_type> __streambuf_type;
+ typedef basic_string<char_type, _Traits, _Alloc> __string_type;
+ typedef typename __string_type::size_type __size_type;
+
+ protected:
+ /// Place to stash in || out || in | out settings for current stringbuf.
+ ios_base::openmode _M_mode;
+
+ // Data Members:
+ __string_type _M_string;
+
+ public:
+ // Constructors:
+ /**
+ * @brief Starts with an empty string buffer.
+ * @param __mode Whether the buffer can read, or write, or both.
+ *
+ * The default constructor initializes the parent class using its
+ * own default ctor.
+ */
+ explicit
+ basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out)
+ : __streambuf_type(), _M_mode(__mode), _M_string()
+ { }
+
+ /**
+ * @brief Starts with an existing string buffer.
+ * @param __str A string to copy as a starting buffer.
+ * @param __mode Whether the buffer can read, or write, or both.
+ *
+ * This constructor initializes the parent class using its
+ * own default ctor.
+ */
+ explicit
+ basic_stringbuf(const __string_type& __str,
+ ios_base::openmode __mode = ios_base::in | ios_base::out)
+ : __streambuf_type(), _M_mode(), _M_string(__str.data(), __str.size())
+ { _M_stringbuf_init(__mode); }
+
+ // Get and set:
+ /**
+ * @brief Copying out the string buffer.
+ * @return A copy of one of the underlying sequences.
+ *
+ * <em>If the buffer is only created in input mode, the underlying
+ * character sequence is equal to the input sequence; otherwise, it
+ * is equal to the output sequence.</em> [27.7.1.2]/1
+ */
+ __string_type
+ str() const
+ {
+ __string_type __ret;
+ if (this->pptr())
+ {
+ // The current egptr() may not be the actual string end.
+ if (this->pptr() > this->egptr())
+ __ret = __string_type(this->pbase(), this->pptr());
+ else
+ __ret = __string_type(this->pbase(), this->egptr());
+ }
+ else
+ __ret = _M_string;
+ return __ret;
+ }
+
+ /**
+ * @brief Setting a new buffer.
+ * @param __s The string to use as a new sequence.
+ *
+ * Deallocates any previous stored sequence, then copies @a s to
+ * use as a new one.
+ */
+ void
+ str(const __string_type& __s)
+ {
+ // Cannot use _M_string = __s, since v3 strings are COW.
+ _M_string.assign(__s.data(), __s.size());
+ _M_stringbuf_init(_M_mode);
+ }
+
+ protected:
+ // Common initialization code goes here.
+ void
+ _M_stringbuf_init(ios_base::openmode __mode)
+ {
+ _M_mode = __mode;
+ __size_type __len = 0;
+ if (_M_mode & (ios_base::ate | ios_base::app))
+ __len = _M_string.size();
+ _M_sync(const_cast<char_type*>(_M_string.data()), 0, __len);
+ }
+
+ virtual streamsize
+ showmanyc()
+ {
+ streamsize __ret = -1;
+ if (_M_mode & ios_base::in)
+ {
+ _M_update_egptr();
+ __ret = this->egptr() - this->gptr();
+ }
+ return __ret;
+ }
+
+ virtual int_type
+ underflow();
+
+ virtual int_type
+ pbackfail(int_type __c = traits_type::eof());
+
+ virtual int_type
+ overflow(int_type __c = traits_type::eof());
+
+ /**
+ * @brief Manipulates the buffer.
+ * @param __s Pointer to a buffer area.
+ * @param __n Size of @a __s.
+ * @return @c this
+ *
+ * If no buffer has already been created, and both @a __s and @a __n are
+ * non-zero, then @c __s is used as a buffer; see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html
+ * for more.
+ */
+ virtual __streambuf_type*
+ setbuf(char_type* __s, streamsize __n)
+ {
+ if (__s && __n >= 0)
+ {
+ // This is implementation-defined behavior, and assumes
+ // that an external char_type array of length __n exists
+ // and has been pre-allocated. If this is not the case,
+ // things will quickly blow up.
+
+ // Step 1: Destroy the current internal array.
+ _M_string.clear();
+
+ // Step 2: Use the external array.
+ _M_sync(__s, __n, 0);
+ }
+ return this;
+ }
+
+ virtual pos_type
+ seekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __mode = ios_base::in | ios_base::out);
+
+ virtual pos_type
+ seekpos(pos_type __sp,
+ ios_base::openmode __mode = ios_base::in | ios_base::out);
+
+ // Internal function for correctly updating the internal buffer
+ // for a particular _M_string, due to initialization or re-sizing
+ // of an existing _M_string.
+ void
+ _M_sync(char_type* __base, __size_type __i, __size_type __o);
+
+ // Internal function for correctly updating egptr() to the actual
+ // string end.
+ void
+ _M_update_egptr()
+ {
+ const bool __testin = _M_mode & ios_base::in;
+ if (this->pptr() && this->pptr() > this->egptr())
+ {
+ if (__testin)
+ this->setg(this->eback(), this->gptr(), this->pptr());
+ else
+ this->setg(this->pptr(), this->pptr(), this->pptr());
+ }
+ }
+
+ // Works around the issue with pbump, part of the protected
+ // interface of basic_streambuf, taking just an int.
+ void
+ _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off);
+ };
+
+
+ // [27.7.2] Template class basic_istringstream
+ /**
+ * @brief Controlling input for std::string.
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ * @tparam _Alloc Allocator type, defaults to allocator<_CharT>.
+ *
+ * This class supports reading from objects of type std::basic_string,
+ * using the inherited functions from std::basic_istream. To control
+ * the associated sequence, an instance of std::basic_stringbuf is used,
+ * which this page refers to as @c sb.
+ */
+ template<typename _CharT, typename _Traits, typename _Alloc>
+ class basic_istringstream : public basic_istream<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 251. basic_stringbuf missing allocator_type
+ typedef _Alloc allocator_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // Non-standard types:
+ typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
+ typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
+ typedef basic_istream<char_type, traits_type> __istream_type;
+
+ private:
+ __stringbuf_type _M_stringbuf;
+
+ public:
+ // Constructors:
+ /**
+ * @brief Default constructor starts with an empty string buffer.
+ * @param __mode Whether the buffer can read, or write, or both.
+ *
+ * @c ios_base::in is automatically included in @a __mode.
+ *
+ * Initializes @c sb using @c __mode|in, and passes @c &sb to the base
+ * class initializer. Does not allocate any buffer.
+ *
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ */
+ explicit
+ basic_istringstream(ios_base::openmode __mode = ios_base::in)
+ : __istream_type(), _M_stringbuf(__mode | ios_base::in)
+ { this->init(&_M_stringbuf); }
+
+ /**
+ * @brief Starts with an existing string buffer.
+ * @param __str A string to copy as a starting buffer.
+ * @param __mode Whether the buffer can read, or write, or both.
+ *
+ * @c ios_base::in is automatically included in @a mode.
+ *
+ * Initializes @c sb using @a str and @c mode|in, and passes @c &sb
+ * to the base class initializer.
+ *
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ */
+ explicit
+ basic_istringstream(const __string_type& __str,
+ ios_base::openmode __mode = ios_base::in)
+ : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in)
+ { this->init(&_M_stringbuf); }
+
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The buffer is deallocated by the stringbuf object, not the
+ * formatting stream.
+ */
+ ~basic_istringstream()
+ { }
+
+ // Members:
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_stringbuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
+ */
+ __stringbuf_type*
+ rdbuf() const
+ { return const_cast<__stringbuf_type*>(&_M_stringbuf); }
+
+ /**
+ * @brief Copying out the string buffer.
+ * @return @c rdbuf()->str()
+ */
+ __string_type
+ str() const
+ { return _M_stringbuf.str(); }
+
+ /**
+ * @brief Setting a new buffer.
+ * @param __s The string to use as a new sequence.
+ *
+ * Calls @c rdbuf()->str(s).
+ */
+ void
+ str(const __string_type& __s)
+ { _M_stringbuf.str(__s); }
+ };
+
+
+ // [27.7.3] Template class basic_ostringstream
+ /**
+ * @brief Controlling output for std::string.
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ * @tparam _Alloc Allocator type, defaults to allocator<_CharT>.
+ *
+ * This class supports writing to objects of type std::basic_string,
+ * using the inherited functions from std::basic_ostream. To control
+ * the associated sequence, an instance of std::basic_stringbuf is used,
+ * which this page refers to as @c sb.
+ */
+ template <typename _CharT, typename _Traits, typename _Alloc>
+ class basic_ostringstream : public basic_ostream<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 251. basic_stringbuf missing allocator_type
+ typedef _Alloc allocator_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // Non-standard types:
+ typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
+ typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
+ typedef basic_ostream<char_type, traits_type> __ostream_type;
+
+ private:
+ __stringbuf_type _M_stringbuf;
+
+ public:
+ // Constructors/destructor:
+ /**
+ * @brief Default constructor starts with an empty string buffer.
+ * @param __mode Whether the buffer can read, or write, or both.
+ *
+ * @c ios_base::out is automatically included in @a mode.
+ *
+ * Initializes @c sb using @c mode|out, and passes @c &sb to the base
+ * class initializer. Does not allocate any buffer.
+ *
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ */
+ explicit
+ basic_ostringstream(ios_base::openmode __mode = ios_base::out)
+ : __ostream_type(), _M_stringbuf(__mode | ios_base::out)
+ { this->init(&_M_stringbuf); }
+
+ /**
+ * @brief Starts with an existing string buffer.
+ * @param __str A string to copy as a starting buffer.
+ * @param __mode Whether the buffer can read, or write, or both.
+ *
+ * @c ios_base::out is automatically included in @a mode.
+ *
+ * Initializes @c sb using @a str and @c mode|out, and passes @c &sb
+ * to the base class initializer.
+ *
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ */
+ explicit
+ basic_ostringstream(const __string_type& __str,
+ ios_base::openmode __mode = ios_base::out)
+ : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out)
+ { this->init(&_M_stringbuf); }
+
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The buffer is deallocated by the stringbuf object, not the
+ * formatting stream.
+ */
+ ~basic_ostringstream()
+ { }
+
+ // Members:
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_stringbuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
+ */
+ __stringbuf_type*
+ rdbuf() const
+ { return const_cast<__stringbuf_type*>(&_M_stringbuf); }
+
+ /**
+ * @brief Copying out the string buffer.
+ * @return @c rdbuf()->str()
+ */
+ __string_type
+ str() const
+ { return _M_stringbuf.str(); }
+
+ /**
+ * @brief Setting a new buffer.
+ * @param __s The string to use as a new sequence.
+ *
+ * Calls @c rdbuf()->str(s).
+ */
+ void
+ str(const __string_type& __s)
+ { _M_stringbuf.str(__s); }
+ };
+
+
+ // [27.7.4] Template class basic_stringstream
+ /**
+ * @brief Controlling input and output for std::string.
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ * @tparam _Alloc Allocator type, defaults to allocator<_CharT>.
+ *
+ * This class supports reading from and writing to objects of type
+ * std::basic_string, using the inherited functions from
+ * std::basic_iostream. To control the associated sequence, an instance
+ * of std::basic_stringbuf is used, which this page refers to as @c sb.
+ */
+ template <typename _CharT, typename _Traits, typename _Alloc>
+ class basic_stringstream : public basic_iostream<_CharT, _Traits>
+ {
+ public:
+ // Types:
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 251. basic_stringbuf missing allocator_type
+ typedef _Alloc allocator_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+
+ // Non-standard Types:
+ typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
+ typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type;
+ typedef basic_iostream<char_type, traits_type> __iostream_type;
+
+ private:
+ __stringbuf_type _M_stringbuf;
+
+ public:
+ // Constructors/destructors
+ /**
+ * @brief Default constructor starts with an empty string buffer.
+ * @param __m Whether the buffer can read, or write, or both.
+ *
+ * Initializes @c sb using the mode from @c __m, and passes @c
+ * &sb to the base class initializer. Does not allocate any
+ * buffer.
+ *
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ */
+ explicit
+ basic_stringstream(ios_base::openmode __m = ios_base::out | ios_base::in)
+ : __iostream_type(), _M_stringbuf(__m)
+ { this->init(&_M_stringbuf); }
+
+ /**
+ * @brief Starts with an existing string buffer.
+ * @param __str A string to copy as a starting buffer.
+ * @param __m Whether the buffer can read, or write, or both.
+ *
+ * Initializes @c sb using @a __str and @c __m, and passes @c &sb
+ * to the base class initializer.
+ *
+ * That's a lie. We initialize the base class with NULL, because the
+ * string class does its own memory management.
+ */
+ explicit
+ basic_stringstream(const __string_type& __str,
+ ios_base::openmode __m = ios_base::out | ios_base::in)
+ : __iostream_type(), _M_stringbuf(__str, __m)
+ { this->init(&_M_stringbuf); }
+
+ /**
+ * @brief The destructor does nothing.
+ *
+ * The buffer is deallocated by the stringbuf object, not the
+ * formatting stream.
+ */
+ ~basic_stringstream()
+ { }
+
+ // Members:
+ /**
+ * @brief Accessing the underlying buffer.
+ * @return The current basic_stringbuf buffer.
+ *
+ * This hides both signatures of std::basic_ios::rdbuf().
+ */
+ __stringbuf_type*
+ rdbuf() const
+ { return const_cast<__stringbuf_type*>(&_M_stringbuf); }
+
+ /**
+ * @brief Copying out the string buffer.
+ * @return @c rdbuf()->str()
+ */
+ __string_type
+ str() const
+ { return _M_stringbuf.str(); }
+
+ /**
+ * @brief Setting a new buffer.
+ * @param __s The string to use as a new sequence.
+ *
+ * Calls @c rdbuf()->str(s).
+ */
+ void
+ str(const __string_type& __s)
+ { _M_stringbuf.str(__s); }
+ };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#include <bits/sstream.tcc>
+
+#endif /* _GLIBCXX_SSTREAM */
diff --git a/gcc-4.9/libstdc++-v3/include/std/stack b/gcc-4.9/libstdc++-v3/include/std/stack
new file mode 100644
index 0000000..07ced5c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/stack
@@ -0,0 +1,63 @@
+// <stack> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/stack
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_STACK
+#define _GLIBCXX_STACK 1
+
+#pragma GCC system_header
+
+#include <deque>
+#include <bits/stl_stack.h>
+
+#endif /* _GLIBCXX_STACK */
diff --git a/gcc-4.9/libstdc++-v3/include/std/stdexcept b/gcc-4.9/libstdc++-v3/include/std/stdexcept
new file mode 100644
index 0000000..ff18405
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/stdexcept
@@ -0,0 +1,158 @@
+// Standard exception classes -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/stdexcept
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 19.1 Exception classes
+//
+
+#ifndef _GLIBCXX_STDEXCEPT
+#define _GLIBCXX_STDEXCEPT 1
+
+#pragma GCC system_header
+
+#include <exception>
+#include <string>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @addtogroup exceptions
+ * @{
+ */
+
+ /** Logic errors represent problems in the internal logic of a program;
+ * in theory, these are preventable, and even detectable before the
+ * program runs (e.g., violations of class invariants).
+ * @brief One of two subclasses of exception.
+ */
+ class logic_error : public exception
+ {
+ string _M_msg;
+
+ public:
+ /** Takes a character string describing the error. */
+ explicit
+ logic_error(const string& __arg);
+
+ virtual ~logic_error() _GLIBCXX_USE_NOEXCEPT;
+
+ /** Returns a C-style character string describing the general cause of
+ * the current error (the same string passed to the ctor). */
+ virtual const char*
+ what() const _GLIBCXX_USE_NOEXCEPT;
+ };
+
+ /** Thrown by the library, or by you, to report domain errors (domain in
+ * the mathematical sense). */
+ class domain_error : public logic_error
+ {
+ public:
+ explicit domain_error(const string& __arg);
+ virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT;
+ };
+
+ /** Thrown to report invalid arguments to functions. */
+ class invalid_argument : public logic_error
+ {
+ public:
+ explicit invalid_argument(const string& __arg);
+ virtual ~invalid_argument() _GLIBCXX_USE_NOEXCEPT;
+ };
+
+ /** Thrown when an object is constructed that would exceed its maximum
+ * permitted size (e.g., a basic_string instance). */
+ class length_error : public logic_error
+ {
+ public:
+ explicit length_error(const string& __arg);
+ virtual ~length_error() _GLIBCXX_USE_NOEXCEPT;
+ };
+
+ /** This represents an argument whose value is not within the expected
+ * range (e.g., boundary checks in basic_string). */
+ class out_of_range : public logic_error
+ {
+ public:
+ explicit out_of_range(const string& __arg);
+ virtual ~out_of_range() _GLIBCXX_USE_NOEXCEPT;
+ };
+
+ /** Runtime errors represent problems outside the scope of a program;
+ * they cannot be easily predicted and can generally only be caught as
+ * the program executes.
+ * @brief One of two subclasses of exception.
+ */
+ class runtime_error : public exception
+ {
+ string _M_msg;
+
+ public:
+ /** Takes a character string describing the error. */
+ explicit
+ runtime_error(const string& __arg);
+
+ virtual ~runtime_error() _GLIBCXX_USE_NOEXCEPT;
+
+ /** Returns a C-style character string describing the general cause of
+ * the current error (the same string passed to the ctor). */
+ virtual const char*
+ what() const _GLIBCXX_USE_NOEXCEPT;
+ };
+
+ /** Thrown to indicate range errors in internal computations. */
+ class range_error : public runtime_error
+ {
+ public:
+ explicit range_error(const string& __arg);
+ virtual ~range_error() _GLIBCXX_USE_NOEXCEPT;
+ };
+
+ /** Thrown to indicate arithmetic overflow. */
+ class overflow_error : public runtime_error
+ {
+ public:
+ explicit overflow_error(const string& __arg);
+ virtual ~overflow_error() _GLIBCXX_USE_NOEXCEPT;
+ };
+
+ /** Thrown to indicate arithmetic underflow. */
+ class underflow_error : public runtime_error
+ {
+ public:
+ explicit underflow_error(const string& __arg);
+ virtual ~underflow_error() _GLIBCXX_USE_NOEXCEPT;
+ };
+
+ // @} group exceptions
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif /* _GLIBCXX_STDEXCEPT */
diff --git a/gcc-4.9/libstdc++-v3/include/std/streambuf b/gcc-4.9/libstdc++-v3/include/std/streambuf
new file mode 100644
index 0000000..865f26b
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/streambuf
@@ -0,0 +1,830 @@
+// Stream buffer classes -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/streambuf
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 27.5 Stream buffers
+//
+
+#ifndef _GLIBXX_STREAMBUF
+#define _GLIBXX_STREAMBUF 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <iosfwd>
+#include <bits/localefwd.h>
+#include <bits/ios_base.h>
+#include <bits/cpp_type_traits.h>
+#include <ext/type_traits.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<typename _CharT, typename _Traits>
+ streamsize
+ __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
+ basic_streambuf<_CharT, _Traits>*, bool&);
+
+ /**
+ * @brief The actual work of input and output (interface).
+ * @ingroup io
+ *
+ * @tparam _CharT Type of character stream.
+ * @tparam _Traits Traits for character type, defaults to
+ * char_traits<_CharT>.
+ *
+ * This is a base class. Derived stream buffers each control a
+ * pair of character sequences: one for input, and one for output.
+ *
+ * Section [27.5.1] of the standard describes the requirements and
+ * behavior of stream buffer classes. That section (three paragraphs)
+ * is reproduced here, for simplicity and accuracy.
+ *
+ * -# Stream buffers can impose various constraints on the sequences
+ * they control. Some constraints are:
+ * - The controlled input sequence can be not readable.
+ * - The controlled output sequence can be not writable.
+ * - The controlled sequences can be associated with the contents of
+ * other representations for character sequences, such as external
+ * files.
+ * - The controlled sequences can support operations @e directly to or
+ * from associated sequences.
+ * - The controlled sequences can impose limitations on how the
+ * program can read characters from a sequence, write characters to
+ * a sequence, put characters back into an input sequence, or alter
+ * the stream position.
+ * .
+ * -# Each sequence is characterized by three pointers which, if non-null,
+ * all point into the same @c charT array object. The array object
+ * represents, at any moment, a (sub)sequence of characters from the
+ * sequence. Operations performed on a sequence alter the values
+ * stored in these pointers, perform reads and writes directly to or
+ * from associated sequences, and alter <em>the stream position</em> and
+ * conversion state as needed to maintain this subsequence relationship.
+ * The three pointers are:
+ * - the <em>beginning pointer</em>, or lowest element address in the
+ * array (called @e xbeg here);
+ * - the <em>next pointer</em>, or next element address that is a
+ * current candidate for reading or writing (called @e xnext here);
+ * - the <em>end pointer</em>, or first element address beyond the
+ * end of the array (called @e xend here).
+ * .
+ * -# The following semantic constraints shall always apply for any set
+ * of three pointers for a sequence, using the pointer names given
+ * immediately above:
+ * - If @e xnext is not a null pointer, then @e xbeg and @e xend shall
+ * also be non-null pointers into the same @c charT array, as
+ * described above; otherwise, @e xbeg and @e xend shall also be null.
+ * - If @e xnext is not a null pointer and @e xnext < @e xend for an
+ * output sequence, then a <em>write position</em> is available.
+ * In this case, @e *xnext shall be assignable as the next element
+ * to write (to put, or to store a character value, into the sequence).
+ * - If @e xnext is not a null pointer and @e xbeg < @e xnext for an
+ * input sequence, then a <em>putback position</em> is available.
+ * In this case, @e xnext[-1] shall have a defined value and is the
+ * next (preceding) element to store a character that is put back
+ * into the input sequence.
+ * - If @e xnext is not a null pointer and @e xnext< @e xend for an
+ * input sequence, then a <em>read position</em> is available.
+ * In this case, @e *xnext shall have a defined value and is the
+ * next element to read (to get, or to obtain a character value,
+ * from the sequence).
+ */
+ template<typename _CharT, typename _Traits>
+ class basic_streambuf
+ {
+ public:
+ //@{
+ /**
+ * These are standard types. They permit a standardized way of
+ * referring to names of (or names dependent on) the template
+ * parameters, which are specific to the implementation.
+ */
+ typedef _CharT char_type;
+ typedef _Traits traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ //@}
+
+ //@{
+ /// This is a non-standard type.
+ typedef basic_streambuf<char_type, traits_type> __streambuf_type;
+ //@}
+
+ friend class basic_ios<char_type, traits_type>;
+ friend class basic_istream<char_type, traits_type>;
+ friend class basic_ostream<char_type, traits_type>;
+ friend class istreambuf_iterator<char_type, traits_type>;
+ friend class ostreambuf_iterator<char_type, traits_type>;
+
+ friend streamsize
+ __copy_streambufs_eof<>(basic_streambuf*, basic_streambuf*, bool&);
+
+ template<bool _IsMove, typename _CharT2>
+ friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
+ _CharT2*>::__type
+ __copy_move_a2(istreambuf_iterator<_CharT2>,
+ istreambuf_iterator<_CharT2>, _CharT2*);
+
+ template<typename _CharT2>
+ friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
+ istreambuf_iterator<_CharT2> >::__type
+ find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
+ const _CharT2&);
+
+ template<typename _CharT2, typename _Traits2>
+ friend basic_istream<_CharT2, _Traits2>&
+ operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
+
+ template<typename _CharT2, typename _Traits2, typename _Alloc>
+ friend basic_istream<_CharT2, _Traits2>&
+ operator>>(basic_istream<_CharT2, _Traits2>&,
+ basic_string<_CharT2, _Traits2, _Alloc>&);
+
+ template<typename _CharT2, typename _Traits2, typename _Alloc>
+ friend basic_istream<_CharT2, _Traits2>&
+ getline(basic_istream<_CharT2, _Traits2>&,
+ basic_string<_CharT2, _Traits2, _Alloc>&, _CharT2);
+
+ protected:
+ /*
+ * This is based on _IO_FILE, just reordered to be more consistent,
+ * and is intended to be the most minimal abstraction for an
+ * internal buffer.
+ * - get == input == read
+ * - put == output == write
+ */
+ char_type* _M_in_beg; ///< Start of get area.
+ char_type* _M_in_cur; ///< Current read area.
+ char_type* _M_in_end; ///< End of get area.
+ char_type* _M_out_beg; ///< Start of put area.
+ char_type* _M_out_cur; ///< Current put area.
+ char_type* _M_out_end; ///< End of put area.
+
+ /// Current locale setting.
+ locale _M_buf_locale;
+
+ public:
+ /// Destructor deallocates no buffer space.
+ virtual
+ ~basic_streambuf()
+ { }
+
+ // [27.5.2.2.1] locales
+ /**
+ * @brief Entry point for imbue().
+ * @param __loc The new locale.
+ * @return The previous locale.
+ *
+ * Calls the derived imbue(__loc).
+ */
+ locale
+ pubimbue(const locale& __loc)
+ {
+ locale __tmp(this->getloc());
+ this->imbue(__loc);
+ _M_buf_locale = __loc;
+ return __tmp;
+ }
+
+ /**
+ * @brief Locale access.
+ * @return The current locale in effect.
+ *
+ * If pubimbue(loc) has been called, then the most recent @c loc
+ * is returned. Otherwise the global locale in effect at the time
+ * of construction is returned.
+ */
+ locale
+ getloc() const
+ { return _M_buf_locale; }
+
+ // [27.5.2.2.2] buffer management and positioning
+ //@{
+ /**
+ * @brief Entry points for derived buffer functions.
+ *
+ * The public versions of @c pubfoo dispatch to the protected
+ * derived @c foo member functions, passing the arguments (if any)
+ * and returning the result unchanged.
+ */
+ basic_streambuf*
+ pubsetbuf(char_type* __s, streamsize __n)
+ { return this->setbuf(__s, __n); }
+
+ /**
+ * @brief Alters the stream position.
+ * @param __off Offset.
+ * @param __way Value for ios_base::seekdir.
+ * @param __mode Value for ios_base::openmode.
+ *
+ * Calls virtual seekoff function.
+ */
+ pos_type
+ pubseekoff(off_type __off, ios_base::seekdir __way,
+ ios_base::openmode __mode = ios_base::in | ios_base::out)
+ { return this->seekoff(__off, __way, __mode); }
+
+ /**
+ * @brief Alters the stream position.
+ * @param __sp Position
+ * @param __mode Value for ios_base::openmode.
+ *
+ * Calls virtual seekpos function.
+ */
+ pos_type
+ pubseekpos(pos_type __sp,
+ ios_base::openmode __mode = ios_base::in | ios_base::out)
+ { return this->seekpos(__sp, __mode); }
+
+ /**
+ * @brief Calls virtual sync function.
+ */
+ int
+ pubsync() { return this->sync(); }
+ //@}
+
+ // [27.5.2.2.3] get area
+ /**
+ * @brief Looking ahead into the stream.
+ * @return The number of characters available.
+ *
+ * If a read position is available, returns the number of characters
+ * available for reading before the buffer must be refilled.
+ * Otherwise returns the derived @c showmanyc().
+ */
+ streamsize
+ in_avail()
+ {
+ const streamsize __ret = this->egptr() - this->gptr();
+ return __ret ? __ret : this->showmanyc();
+ }
+
+ /**
+ * @brief Getting the next character.
+ * @return The next character, or eof.
+ *
+ * Calls @c sbumpc(), and if that function returns
+ * @c traits::eof(), so does this function. Otherwise, @c sgetc().
+ */
+ int_type
+ snextc()
+ {
+ int_type __ret = traits_type::eof();
+ if (__builtin_expect(!traits_type::eq_int_type(this->sbumpc(),
+ __ret), true))
+ __ret = this->sgetc();
+ return __ret;
+ }
+
+ /**
+ * @brief Getting the next character.
+ * @return The next character, or eof.
+ *
+ * If the input read position is available, returns that character
+ * and increments the read pointer, otherwise calls and returns
+ * @c uflow().
+ */
+ int_type
+ sbumpc()
+ {
+ int_type __ret;
+ if (__builtin_expect(this->gptr() < this->egptr(), true))
+ {
+ __ret = traits_type::to_int_type(*this->gptr());
+ this->gbump(1);
+ }
+ else
+ __ret = this->uflow();
+ return __ret;
+ }
+
+ /**
+ * @brief Getting the next character.
+ * @return The next character, or eof.
+ *
+ * If the input read position is available, returns that character,
+ * otherwise calls and returns @c underflow(). Does not move the
+ * read position after fetching the character.
+ */
+ int_type
+ sgetc()
+ {
+ int_type __ret;
+ if (__builtin_expect(this->gptr() < this->egptr(), true))
+ __ret = traits_type::to_int_type(*this->gptr());
+ else
+ __ret = this->underflow();
+ return __ret;
+ }
+
+ /**
+ * @brief Entry point for xsgetn.
+ * @param __s A buffer area.
+ * @param __n A count.
+ *
+ * Returns xsgetn(__s,__n). The effect is to fill @a __s[0] through
+ * @a __s[__n-1] with characters from the input sequence, if possible.
+ */
+ streamsize
+ sgetn(char_type* __s, streamsize __n)
+ { return this->xsgetn(__s, __n); }
+
+ // [27.5.2.2.4] putback
+ /**
+ * @brief Pushing characters back into the input stream.
+ * @param __c The character to push back.
+ * @return The previous character, if possible.
+ *
+ * Similar to sungetc(), but @a __c is pushed onto the stream
+ * instead of <em>the previous character.</em> If successful,
+ * the next character fetched from the input stream will be @a
+ * __c.
+ */
+ int_type
+ sputbackc(char_type __c)
+ {
+ int_type __ret;
+ const bool __testpos = this->eback() < this->gptr();
+ if (__builtin_expect(!__testpos ||
+ !traits_type::eq(__c, this->gptr()[-1]), false))
+ __ret = this->pbackfail(traits_type::to_int_type(__c));
+ else
+ {
+ this->gbump(-1);
+ __ret = traits_type::to_int_type(*this->gptr());
+ }
+ return __ret;
+ }
+
+ /**
+ * @brief Moving backwards in the input stream.
+ * @return The previous character, if possible.
+ *
+ * If a putback position is available, this function decrements
+ * the input pointer and returns that character. Otherwise,
+ * calls and returns pbackfail(). The effect is to @a unget
+ * the last character @a gotten.
+ */
+ int_type
+ sungetc()
+ {
+ int_type __ret;
+ if (__builtin_expect(this->eback() < this->gptr(), true))
+ {
+ this->gbump(-1);
+ __ret = traits_type::to_int_type(*this->gptr());
+ }
+ else
+ __ret = this->pbackfail();
+ return __ret;
+ }
+
+ // [27.5.2.2.5] put area
+ /**
+ * @brief Entry point for all single-character output functions.
+ * @param __c A character to output.
+ * @return @a __c, if possible.
+ *
+ * One of two public output functions.
+ *
+ * If a write position is available for the output sequence (i.e.,
+ * the buffer is not full), stores @a __c in that position, increments
+ * the position, and returns @c traits::to_int_type(__c). If a write
+ * position is not available, returns @c overflow(__c).
+ */
+ int_type
+ sputc(char_type __c)
+ {
+ int_type __ret;
+ if (__builtin_expect(this->pptr() < this->epptr(), true))
+ {
+ *this->pptr() = __c;
+ this->pbump(1);
+ __ret = traits_type::to_int_type(__c);
+ }
+ else
+ __ret = this->overflow(traits_type::to_int_type(__c));
+ return __ret;
+ }
+
+ /**
+ * @brief Entry point for all single-character output functions.
+ * @param __s A buffer read area.
+ * @param __n A count.
+ *
+ * One of two public output functions.
+ *
+ *
+ * Returns xsputn(__s,__n). The effect is to write @a __s[0] through
+ * @a __s[__n-1] to the output sequence, if possible.
+ */
+ streamsize
+ sputn(const char_type* __s, streamsize __n)
+ { return this->xsputn(__s, __n); }
+
+ protected:
+ /**
+ * @brief Base constructor.
+ *
+ * Only called from derived constructors, and sets up all the
+ * buffer data to zero, including the pointers described in the
+ * basic_streambuf class description. Note that, as a result,
+ * - the class starts with no read nor write positions available,
+ * - this is not an error
+ */
+ basic_streambuf()
+ : _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
+ _M_out_beg(0), _M_out_cur(0), _M_out_end(0),
+ _M_buf_locale(locale())
+ { }
+
+ // [27.5.2.3.1] get area access
+ //@{
+ /**
+ * @brief Access to the get area.
+ *
+ * These functions are only available to other protected functions,
+ * including derived classes.
+ *
+ * - eback() returns the beginning pointer for the input sequence
+ * - gptr() returns the next pointer for the input sequence
+ * - egptr() returns the end pointer for the input sequence
+ */
+ char_type*
+ eback() const { return _M_in_beg; }
+
+ char_type*
+ gptr() const { return _M_in_cur; }
+
+ char_type*
+ egptr() const { return _M_in_end; }
+ //@}
+
+ /**
+ * @brief Moving the read position.
+ * @param __n The delta by which to move.
+ *
+ * This just advances the read position without returning any data.
+ */
+ void
+ gbump(int __n) { _M_in_cur += __n; }
+
+ /**
+ * @brief Setting the three read area pointers.
+ * @param __gbeg A pointer.
+ * @param __gnext A pointer.
+ * @param __gend A pointer.
+ * @post @a __gbeg == @c eback(), @a __gnext == @c gptr(), and
+ * @a __gend == @c egptr()
+ */
+ void
+ setg(char_type* __gbeg, char_type* __gnext, char_type* __gend)
+ {
+ _M_in_beg = __gbeg;
+ _M_in_cur = __gnext;
+ _M_in_end = __gend;
+ }
+
+ // [27.5.2.3.2] put area access
+ //@{
+ /**
+ * @brief Access to the put area.
+ *
+ * These functions are only available to other protected functions,
+ * including derived classes.
+ *
+ * - pbase() returns the beginning pointer for the output sequence
+ * - pptr() returns the next pointer for the output sequence
+ * - epptr() returns the end pointer for the output sequence
+ */
+ char_type*
+ pbase() const { return _M_out_beg; }
+
+ char_type*
+ pptr() const { return _M_out_cur; }
+
+ char_type*
+ epptr() const { return _M_out_end; }
+ //@}
+
+ /**
+ * @brief Moving the write position.
+ * @param __n The delta by which to move.
+ *
+ * This just advances the write position without returning any data.
+ */
+ void
+ pbump(int __n) { _M_out_cur += __n; }
+
+ /**
+ * @brief Setting the three write area pointers.
+ * @param __pbeg A pointer.
+ * @param __pend A pointer.
+ * @post @a __pbeg == @c pbase(), @a __pbeg == @c pptr(), and
+ * @a __pend == @c epptr()
+ */
+ void
+ setp(char_type* __pbeg, char_type* __pend)
+ {
+ _M_out_beg = _M_out_cur = __pbeg;
+ _M_out_end = __pend;
+ }
+
+ // [27.5.2.4] virtual functions
+ // [27.5.2.4.1] locales
+ /**
+ * @brief Changes translations.
+ * @param __loc A new locale.
+ *
+ * Translations done during I/O which depend on the current
+ * locale are changed by this call. The standard adds,
+ * <em>Between invocations of this function a class derived
+ * from streambuf can safely cache results of calls to locale
+ * functions and to members of facets so obtained.</em>
+ *
+ * @note Base class version does nothing.
+ */
+ virtual void
+ imbue(const locale& __loc)
+ { }
+
+ // [27.5.2.4.2] buffer management and positioning
+ /**
+ * @brief Manipulates the buffer.
+ *
+ * Each derived class provides its own appropriate behavior. See
+ * the next-to-last paragraph of
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html
+ * for more on this function.
+ *
+ * @note Base class version does nothing, returns @c this.
+ */
+ virtual basic_streambuf<char_type,_Traits>*
+ setbuf(char_type*, streamsize)
+ { return this; }
+
+ /**
+ * @brief Alters the stream positions.
+ *
+ * Each derived class provides its own appropriate behavior.
+ * @note Base class version does nothing, returns a @c pos_type
+ * that represents an invalid stream position.
+ */
+ virtual pos_type
+ seekoff(off_type, ios_base::seekdir,
+ ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
+ { return pos_type(off_type(-1)); }
+
+ /**
+ * @brief Alters the stream positions.
+ *
+ * Each derived class provides its own appropriate behavior.
+ * @note Base class version does nothing, returns a @c pos_type
+ * that represents an invalid stream position.
+ */
+ virtual pos_type
+ seekpos(pos_type,
+ ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
+ { return pos_type(off_type(-1)); }
+
+ /**
+ * @brief Synchronizes the buffer arrays with the controlled sequences.
+ * @return -1 on failure.
+ *
+ * Each derived class provides its own appropriate behavior,
+ * including the definition of @a failure.
+ * @note Base class version does nothing, returns zero.
+ */
+ virtual int
+ sync() { return 0; }
+
+ // [27.5.2.4.3] get area
+ /**
+ * @brief Investigating the data available.
+ * @return An estimate of the number of characters available in the
+ * input sequence, or -1.
+ *
+ * <em>If it returns a positive value, then successive calls to
+ * @c underflow() will not return @c traits::eof() until at
+ * least that number of characters have been supplied. If @c
+ * showmanyc() returns -1, then calls to @c underflow() or @c
+ * uflow() will fail.</em> [27.5.2.4.3]/1
+ *
+ * @note Base class version does nothing, returns zero.
+ * @note The standard adds that <em>the intention is not only that the
+ * calls [to underflow or uflow] will not return @c eof() but
+ * that they will return immediately.</em>
+ * @note The standard adds that <em>the morphemes of @c showmanyc are
+ * @b es-how-many-see, not @b show-manic.</em>
+ */
+ virtual streamsize
+ showmanyc() { return 0; }
+
+ /**
+ * @brief Multiple character extraction.
+ * @param __s A buffer area.
+ * @param __n Maximum number of characters to assign.
+ * @return The number of characters assigned.
+ *
+ * Fills @a __s[0] through @a __s[__n-1] with characters from the input
+ * sequence, as if by @c sbumpc(). Stops when either @a __n characters
+ * have been copied, or when @c traits::eof() would be copied.
+ *
+ * It is expected that derived classes provide a more efficient
+ * implementation by overriding this definition.
+ */
+ virtual streamsize
+ xsgetn(char_type* __s, streamsize __n);
+
+ /**
+ * @brief Fetches more data from the controlled sequence.
+ * @return The first character from the <em>pending sequence</em>.
+ *
+ * Informally, this function is called when the input buffer is
+ * exhausted (or does not exist, as buffering need not actually be
+ * done). If a buffer exists, it is @a refilled. In either case, the
+ * next available character is returned, or @c traits::eof() to
+ * indicate a null pending sequence.
+ *
+ * For a formal definition of the pending sequence, see a good text
+ * such as Langer & Kreft, or [27.5.2.4.3]/7-14.
+ *
+ * A functioning input streambuf can be created by overriding only
+ * this function (no buffer area will be used). For an example, see
+ * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25.html
+ *
+ * @note Base class version does nothing, returns eof().
+ */
+ virtual int_type
+ underflow()
+ { return traits_type::eof(); }
+
+ /**
+ * @brief Fetches more data from the controlled sequence.
+ * @return The first character from the <em>pending sequence</em>.
+ *
+ * Informally, this function does the same thing as @c underflow(),
+ * and in fact is required to call that function. It also returns
+ * the new character, like @c underflow() does. However, this
+ * function also moves the read position forward by one.
+ */
+ virtual int_type
+ uflow()
+ {
+ int_type __ret = traits_type::eof();
+ const bool __testeof = traits_type::eq_int_type(this->underflow(),
+ __ret);
+ if (!__testeof)
+ {
+ __ret = traits_type::to_int_type(*this->gptr());
+ this->gbump(1);
+ }
+ return __ret;
+ }
+
+ // [27.5.2.4.4] putback
+ /**
+ * @brief Tries to back up the input sequence.
+ * @param __c The character to be inserted back into the sequence.
+ * @return eof() on failure, <em>some other value</em> on success
+ * @post The constraints of @c gptr(), @c eback(), and @c pptr()
+ * are the same as for @c underflow().
+ *
+ * @note Base class version does nothing, returns eof().
+ */
+ virtual int_type
+ pbackfail(int_type __c = traits_type::eof())
+ { return traits_type::eof(); }
+
+ // Put area:
+ /**
+ * @brief Multiple character insertion.
+ * @param __s A buffer area.
+ * @param __n Maximum number of characters to write.
+ * @return The number of characters written.
+ *
+ * Writes @a __s[0] through @a __s[__n-1] to the output sequence, as if
+ * by @c sputc(). Stops when either @a n characters have been
+ * copied, or when @c sputc() would return @c traits::eof().
+ *
+ * It is expected that derived classes provide a more efficient
+ * implementation by overriding this definition.
+ */
+ virtual streamsize
+ xsputn(const char_type* __s, streamsize __n);
+
+ /**
+ * @brief Consumes data from the buffer; writes to the
+ * controlled sequence.
+ * @param __c An additional character to consume.
+ * @return eof() to indicate failure, something else (usually
+ * @a __c, or not_eof())
+ *
+ * Informally, this function is called when the output buffer
+ * is full (or does not exist, as buffering need not actually
+ * be done). If a buffer exists, it is @a consumed, with
+ * <em>some effect</em> on the controlled sequence.
+ * (Typically, the buffer is written out to the sequence
+ * verbatim.) In either case, the character @a c is also
+ * written out, if @a __c is not @c eof().
+ *
+ * For a formal definition of this function, see a good text
+ * such as Langer & Kreft, or [27.5.2.4.5]/3-7.
+ *
+ * A functioning output streambuf can be created by overriding only
+ * this function (no buffer area will be used).
+ *
+ * @note Base class version does nothing, returns eof().
+ */
+ virtual int_type
+ overflow(int_type __c = traits_type::eof())
+ { return traits_type::eof(); }
+
+#if _GLIBCXX_USE_DEPRECATED
+ // Annex D.6
+ public:
+ /**
+ * @brief Tosses a character.
+ *
+ * Advances the read pointer, ignoring the character that would have
+ * been read.
+ *
+ * See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html
+ */
+ void
+ stossc()
+ {
+ if (this->gptr() < this->egptr())
+ this->gbump(1);
+ else
+ this->uflow();
+ }
+#endif
+
+ // Also used by specializations for char and wchar_t in src.
+ void
+ __safe_gbump(streamsize __n) { _M_in_cur += __n; }
+
+ void
+ __safe_pbump(streamsize __n) { _M_out_cur += __n; }
+
+ private:
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // Side effect of DR 50.
+ basic_streambuf(const basic_streambuf& __sb)
+ : _M_in_beg(__sb._M_in_beg), _M_in_cur(__sb._M_in_cur),
+ _M_in_end(__sb._M_in_end), _M_out_beg(__sb._M_out_beg),
+ _M_out_cur(__sb._M_out_cur), _M_out_end(__sb._M_out_cur),
+ _M_buf_locale(__sb._M_buf_locale)
+ { }
+
+ basic_streambuf&
+ operator=(const basic_streambuf&) { return *this; };
+ };
+
+ // Explicit specialization declarations, defined in src/streambuf.cc.
+ template<>
+ streamsize
+ __copy_streambufs_eof(basic_streambuf<char>* __sbin,
+ basic_streambuf<char>* __sbout, bool& __ineof);
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template<>
+ streamsize
+ __copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin,
+ basic_streambuf<wchar_t>* __sbout, bool& __ineof);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#include <bits/streambuf.tcc>
+
+#endif /* _GLIBCXX_STREAMBUF */
diff --git a/gcc-4.9/libstdc++-v3/include/std/string b/gcc-4.9/libstdc++-v3/include/std/string
new file mode 100644
index 0000000..08d2e26
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/string
@@ -0,0 +1,55 @@
+// Components for manipulating sequences of characters -*- C++ -*-
+
+// Copyright (C) 1997-2014 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/string
+ * This is a Standard C++ Library header.
+ */
+
+//
+// ISO C++ 14882: 21 Strings library
+//
+
+#ifndef _GLIBCXX_STRING
+#define _GLIBCXX_STRING 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <bits/stringfwd.h>
+#include <bits/char_traits.h> // NB: In turn includes stl_algobase.h
+#include <bits/allocator.h>
+#include <bits/cpp_type_traits.h>
+#include <bits/localefwd.h> // For operators >>, <<, and getline.
+#include <bits/ostream_insert.h>
+#include <bits/stl_iterator_base_types.h>
+#include <bits/stl_iterator_base_funcs.h>
+#include <bits/stl_iterator.h>
+#include <bits/stl_function.h> // For less
+#include <ext/numeric_traits.h>
+#include <bits/stl_algobase.h>
+#include <bits/range_access.h>
+#include <bits/basic_string.h>
+#include <bits/basic_string.tcc>
+
+#endif /* _GLIBCXX_STRING */
diff --git a/gcc-4.9/libstdc++-v3/include/std/system_error b/gcc-4.9/libstdc++-v3/include/std/system_error
new file mode 100644
index 0000000..4ec83d7
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/system_error
@@ -0,0 +1,381 @@
+// <system_error> -*- C++ -*-
+
+// Copyright (C) 2007-2014 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/system_error
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_SYSTEM_ERROR
+#define _GLIBCXX_SYSTEM_ERROR 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <bits/c++config.h>
+#include <bits/error_constants.h>
+#include <iosfwd>
+#include <stdexcept>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ class error_code;
+ class error_condition;
+ class error_category;
+ class system_error;
+
+ /// is_error_code_enum
+ template<typename _Tp>
+ struct is_error_code_enum : public false_type { };
+
+ /// is_error_condition_enum
+ template<typename _Tp>
+ struct is_error_condition_enum : public false_type { };
+
+ template<>
+ struct is_error_condition_enum<errc>
+ : public true_type { };
+
+
+ /// error_category
+ class error_category
+ {
+ public:
+#ifdef _GLIBCXX_COMPATIBILITY_CXX0X
+ error_category() noexcept;
+#else
+ constexpr error_category() noexcept = default;
+#endif
+
+ virtual ~error_category();
+
+ error_category(const error_category&) = delete;
+ error_category& operator=(const error_category&) = delete;
+
+ virtual const char*
+ name() const noexcept = 0;
+
+ virtual string
+ message(int) const = 0;
+
+ virtual error_condition
+ default_error_condition(int __i) const noexcept;
+
+ virtual bool
+ equivalent(int __i, const error_condition& __cond) const noexcept;
+
+ virtual bool
+ equivalent(const error_code& __code, int __i) const noexcept;
+
+ bool
+ operator<(const error_category& __other) const noexcept
+ { return less<const error_category*>()(this, &__other); }
+
+ bool
+ operator==(const error_category& __other) const noexcept
+ { return this == &__other; }
+
+ bool
+ operator!=(const error_category& __other) const noexcept
+ { return this != &__other; }
+ };
+
+ // DR 890.
+ _GLIBCXX_CONST const error_category& system_category() noexcept;
+ _GLIBCXX_CONST const error_category& generic_category() noexcept;
+
+ error_code make_error_code(errc) noexcept;
+
+ template<typename _Tp>
+ struct hash;
+
+ /// error_code
+ // Implementation-specific error identification
+ struct error_code
+ {
+ error_code() noexcept
+ : _M_value(0), _M_cat(&system_category()) { }
+
+ error_code(int __v, const error_category& __cat) noexcept
+ : _M_value(__v), _M_cat(&__cat) { }
+
+ template<typename _ErrorCodeEnum, typename = typename
+ enable_if<is_error_code_enum<_ErrorCodeEnum>::value>::type>
+ error_code(_ErrorCodeEnum __e) noexcept
+ { *this = make_error_code(__e); }
+
+ void
+ assign(int __v, const error_category& __cat) noexcept
+ {
+ _M_value = __v;
+ _M_cat = &__cat;
+ }
+
+ void
+ clear() noexcept
+ { assign(0, system_category()); }
+
+ // DR 804.
+ template<typename _ErrorCodeEnum>
+ typename enable_if<is_error_code_enum<_ErrorCodeEnum>::value,
+ error_code&>::type
+ operator=(_ErrorCodeEnum __e) noexcept
+ { return *this = make_error_code(__e); }
+
+ int
+ value() const noexcept { return _M_value; }
+
+ const error_category&
+ category() const noexcept { return *_M_cat; }
+
+ error_condition
+ default_error_condition() const noexcept;
+
+ string
+ message() const
+ { return category().message(value()); }
+
+ explicit operator bool() const noexcept
+ { return _M_value != 0 ? true : false; }
+
+ // DR 804.
+ private:
+ friend class hash<error_code>;
+
+ int _M_value;
+ const error_category* _M_cat;
+ };
+
+ // 19.4.2.6 non-member functions
+ inline error_code
+ make_error_code(errc __e) noexcept
+ { return error_code(static_cast<int>(__e), generic_category()); }
+
+ inline bool
+ operator<(const error_code& __lhs, const error_code& __rhs) noexcept
+ {
+ return (__lhs.category() < __rhs.category()
+ || (__lhs.category() == __rhs.category()
+ && __lhs.value() < __rhs.value()));
+ }
+
+ template<typename _CharT, typename _Traits>
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
+ { return (__os << __e.category().name() << ':' << __e.value()); }
+
+ error_condition make_error_condition(errc) noexcept;
+
+ /// error_condition
+ // Portable error identification
+ struct error_condition
+ {
+ error_condition() noexcept
+ : _M_value(0), _M_cat(&generic_category()) { }
+
+ error_condition(int __v, const error_category& __cat) noexcept
+ : _M_value(__v), _M_cat(&__cat) { }
+
+ template<typename _ErrorConditionEnum, typename = typename
+ enable_if<is_error_condition_enum<_ErrorConditionEnum>::value>::type>
+ error_condition(_ErrorConditionEnum __e) noexcept
+ { *this = make_error_condition(__e); }
+
+ void
+ assign(int __v, const error_category& __cat) noexcept
+ {
+ _M_value = __v;
+ _M_cat = &__cat;
+ }
+
+ // DR 804.
+ template<typename _ErrorConditionEnum>
+ typename enable_if<is_error_condition_enum
+ <_ErrorConditionEnum>::value, error_condition&>::type
+ operator=(_ErrorConditionEnum __e) noexcept
+ { return *this = make_error_condition(__e); }
+
+ void
+ clear() noexcept
+ { assign(0, generic_category()); }
+
+ // 19.4.3.4 observers
+ int
+ value() const noexcept { return _M_value; }
+
+ const error_category&
+ category() const noexcept { return *_M_cat; }
+
+ string
+ message() const
+ { return category().message(value()); }
+
+ explicit operator bool() const noexcept
+ { return _M_value != 0 ? true : false; }
+
+ // DR 804.
+ private:
+ int _M_value;
+ const error_category* _M_cat;
+ };
+
+ // 19.4.3.6 non-member functions
+ inline error_condition
+ make_error_condition(errc __e) noexcept
+ { return error_condition(static_cast<int>(__e), generic_category()); }
+
+ inline bool
+ operator<(const error_condition& __lhs,
+ const error_condition& __rhs) noexcept
+ {
+ return (__lhs.category() < __rhs.category()
+ || (__lhs.category() == __rhs.category()
+ && __lhs.value() < __rhs.value()));
+ }
+
+ // 19.4.4 Comparison operators
+ inline bool
+ operator==(const error_code& __lhs, const error_code& __rhs) noexcept
+ { return (__lhs.category() == __rhs.category()
+ && __lhs.value() == __rhs.value()); }
+
+ inline bool
+ operator==(const error_code& __lhs, const error_condition& __rhs) noexcept
+ {
+ return (__lhs.category().equivalent(__lhs.value(), __rhs)
+ || __rhs.category().equivalent(__lhs, __rhs.value()));
+ }
+
+ inline bool
+ operator==(const error_condition& __lhs, const error_code& __rhs) noexcept
+ {
+ return (__rhs.category().equivalent(__rhs.value(), __lhs)
+ || __lhs.category().equivalent(__rhs, __lhs.value()));
+ }
+
+ inline bool
+ operator==(const error_condition& __lhs,
+ const error_condition& __rhs) noexcept
+ {
+ return (__lhs.category() == __rhs.category()
+ && __lhs.value() == __rhs.value());
+ }
+
+ inline bool
+ operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
+ { return !(__lhs == __rhs); }
+
+ inline bool
+ operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
+ { return !(__lhs == __rhs); }
+
+ inline bool
+ operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
+ { return !(__lhs == __rhs); }
+
+ inline bool
+ operator!=(const error_condition& __lhs,
+ const error_condition& __rhs) noexcept
+ { return !(__lhs == __rhs); }
+
+
+ /**
+ * @brief Thrown to indicate error code of underlying system.
+ *
+ * @ingroup exceptions
+ */
+ class system_error : public std::runtime_error
+ {
+ private:
+ error_code _M_code;
+
+ public:
+ system_error(error_code __ec = error_code())
+ : runtime_error(__ec.message()), _M_code(__ec) { }
+
+ system_error(error_code __ec, const string& __what)
+ : runtime_error(__what + ": " + __ec.message()), _M_code(__ec) { }
+
+ /*
+ * TODO: Add const char* ctors to all exceptions.
+ *
+ * system_error(error_code __ec, const char* __what)
+ * : runtime_error(__what + (": " + __ec.message())), _M_code(__ec) { }
+ *
+ * system_error(int __v, const error_category& __ecat, const char* __what)
+ * : runtime_error(__what + (": " + __ec.message())),
+ * _M_code(error_code(__v, __ecat)) { }
+ */
+
+ system_error(int __v, const error_category& __ecat)
+ : runtime_error(error_code(__v, __ecat).message()),
+ _M_code(__v, __ecat) { }
+
+ system_error(int __v, const error_category& __ecat, const string& __what)
+ : runtime_error(__what + ": " + error_code(__v, __ecat).message()),
+ _M_code(__v, __ecat) { }
+
+ virtual ~system_error() noexcept;
+
+ const error_code&
+ code() const noexcept { return _M_code; }
+ };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
+
+#include <bits/functional_hash.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // DR 1182.
+ /// std::hash specialization for error_code.
+ template<>
+ struct hash<error_code>
+ : public __hash_base<size_t, error_code>
+ {
+ size_t
+ operator()(const error_code& __e) const noexcept
+ {
+ const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
+ return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
+ }
+ };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif // _GLIBCXX_COMPATIBILITY_CXX0X
+
+#endif // C++11
+
+#endif // _GLIBCXX_SYSTEM_ERROR
diff --git a/gcc-4.9/libstdc++-v3/include/std/thread b/gcc-4.9/libstdc++-v3/include/std/thread
new file mode 100644
index 0000000..efcb101
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/thread
@@ -0,0 +1,302 @@
+// <thread> -*- C++ -*-
+
+// Copyright (C) 2008-2014 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/thread
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_THREAD
+#define _GLIBCXX_THREAD 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <chrono>
+#include <functional>
+#include <memory>
+#include <bits/functexcept.h>
+#include <bits/functional_hash.h>
+#include <bits/gthr.h>
+
+#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @defgroup threads Threads
+ * @ingroup concurrency
+ *
+ * Classes for thread support.
+ * @{
+ */
+
+ /// thread
+ class thread
+ {
+ public:
+ typedef __gthread_t native_handle_type;
+ struct _Impl_base;
+ typedef shared_ptr<_Impl_base> __shared_base_type;
+
+ /// thread::id
+ class id
+ {
+ native_handle_type _M_thread;
+
+ public:
+ id() noexcept : _M_thread() { }
+
+ explicit
+ id(native_handle_type __id) : _M_thread(__id) { }
+
+ private:
+ friend class thread;
+ friend class hash<thread::id>;
+
+ friend bool
+ operator==(thread::id __x, thread::id __y) noexcept
+ { return __gthread_equal(__x._M_thread, __y._M_thread); }
+
+ friend bool
+ operator<(thread::id __x, thread::id __y) noexcept
+ { return __x._M_thread < __y._M_thread; }
+
+ template<class _CharT, class _Traits>
+ friend basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __out, thread::id __id);
+ };
+
+ // Simple base type that the templatized, derived class containing
+ // an arbitrary functor can be converted to and called.
+ struct _Impl_base
+ {
+ __shared_base_type _M_this_ptr;
+
+ inline virtual ~_Impl_base();
+
+ virtual void _M_run() = 0;
+ };
+
+ template<typename _Callable>
+ struct _Impl : public _Impl_base
+ {
+ _Callable _M_func;
+
+ _Impl(_Callable&& __f) : _M_func(std::forward<_Callable>(__f))
+ { }
+
+ void
+ _M_run() { _M_func(); }
+ };
+
+ private:
+ id _M_id;
+
+ public:
+ thread() noexcept = default;
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2097. packaged_task constructors should be constrained
+ thread(thread&) = delete;
+ thread(const thread&) = delete;
+
+ thread(thread&& __t) noexcept
+ { swap(__t); }
+
+ template<typename _Callable, typename... _Args>
+ explicit
+ thread(_Callable&& __f, _Args&&... __args)
+ {
+ _M_start_thread(_M_make_routine(std::__bind_simple(
+ std::forward<_Callable>(__f),
+ std::forward<_Args>(__args)...)));
+ }
+
+ ~thread()
+ {
+ if (joinable())
+ std::terminate();
+ }
+
+ thread& operator=(const thread&) = delete;
+
+ thread& operator=(thread&& __t) noexcept
+ {
+ if (joinable())
+ std::terminate();
+ swap(__t);
+ return *this;
+ }
+
+ void
+ swap(thread& __t) noexcept
+ { std::swap(_M_id, __t._M_id); }
+
+ bool
+ joinable() const noexcept
+ { return !(_M_id == id()); }
+
+ void
+ join();
+
+ void
+ detach();
+
+ thread::id
+ get_id() const noexcept
+ { return _M_id; }
+
+ /** @pre thread is joinable
+ */
+ native_handle_type
+ native_handle()
+ { return _M_id._M_thread; }
+
+ // Returns a value that hints at the number of hardware thread contexts.
+ static unsigned int
+ hardware_concurrency() noexcept;
+
+ private:
+ void
+ _M_start_thread(__shared_base_type);
+
+ template<typename _Callable>
+ shared_ptr<_Impl<_Callable>>
+ _M_make_routine(_Callable&& __f)
+ {
+ // Create and allocate full data structure, not base.
+ return std::make_shared<_Impl<_Callable>>(std::forward<_Callable>(__f));
+ }
+ };
+
+ inline thread::_Impl_base::~_Impl_base() = default;
+
+ inline void
+ swap(thread& __x, thread& __y) noexcept
+ { __x.swap(__y); }
+
+ inline bool
+ operator!=(thread::id __x, thread::id __y) noexcept
+ { return !(__x == __y); }
+
+ inline bool
+ operator<=(thread::id __x, thread::id __y) noexcept
+ { return !(__y < __x); }
+
+ inline bool
+ operator>(thread::id __x, thread::id __y) noexcept
+ { return __y < __x; }
+
+ inline bool
+ operator>=(thread::id __x, thread::id __y) noexcept
+ { return !(__x < __y); }
+
+ // DR 889.
+ /// std::hash specialization for thread::id.
+ template<>
+ struct hash<thread::id>
+ : public __hash_base<size_t, thread::id>
+ {
+ size_t
+ operator()(const thread::id& __id) const noexcept
+ { return std::_Hash_impl::hash(__id._M_thread); }
+ };
+
+ template<class _CharT, class _Traits>
+ inline basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __out, thread::id __id)
+ {
+ if (__id == thread::id())
+ return __out << "thread::id of a non-executing thread";
+ else
+ return __out << __id._M_thread;
+ }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+
+ /** @namespace std::this_thread
+ * @brief ISO C++ 2011 entities sub-namespace for thread.
+ * 30.3.2 Namespace this_thread.
+ */
+ namespace this_thread
+ {
+ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /// get_id
+ inline thread::id
+ get_id() noexcept { return thread::id(__gthread_self()); }
+
+ /// yield
+ inline void
+ yield() noexcept
+ {
+#ifdef _GLIBCXX_USE_SCHED_YIELD
+ __gthread_yield();
+#endif
+ }
+
+ void
+ __sleep_for(chrono::seconds, chrono::nanoseconds);
+
+ /// sleep_for
+ template<typename _Rep, typename _Period>
+ inline void
+ sleep_for(const chrono::duration<_Rep, _Period>& __rtime)
+ {
+ auto __s = chrono::duration_cast<chrono::seconds>(__rtime);
+ auto __ns = chrono::duration_cast<chrono::nanoseconds>(__rtime - __s);
+#ifdef _GLIBCXX_USE_NANOSLEEP
+ __gthread_time_t __ts =
+ {
+ static_cast<std::time_t>(__s.count()),
+ static_cast<long>(__ns.count())
+ };
+ ::nanosleep(&__ts, 0);
+#else
+ __sleep_for(__s, __ns);
+#endif
+ }
+
+ /// sleep_until
+ template<typename _Clock, typename _Duration>
+ inline void
+ sleep_until(const chrono::time_point<_Clock, _Duration>& __atime)
+ { sleep_for(__atime - _Clock::now()); }
+
+ _GLIBCXX_END_NAMESPACE_VERSION
+ }
+
+ // @} group threads
+
+} // namespace
+
+#endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
+
+#endif // C++11
+
+#endif // _GLIBCXX_THREAD
diff --git a/gcc-4.9/libstdc++-v3/include/std/tuple b/gcc-4.9/libstdc++-v3/include/std/tuple
new file mode 100644
index 0000000..92ecdb9
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/tuple
@@ -0,0 +1,1104 @@
+// <tuple> -*- C++ -*-
+
+// Copyright (C) 2007-2014 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/tuple
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_TUPLE
+#define _GLIBCXX_TUPLE 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <utility>
+#include <array>
+#include <bits/uses_allocator.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @addtogroup utilities
+ * @{
+ */
+
+ // Adds a const reference to a non-reference type.
+ template<typename _Tp>
+ struct __add_c_ref
+ { typedef const _Tp& type; };
+
+ template<typename _Tp>
+ struct __add_c_ref<_Tp&>
+ { typedef _Tp& type; };
+
+ // Adds a reference to a non-reference type.
+ template<typename _Tp>
+ struct __add_ref
+ { typedef _Tp& type; };
+
+ template<typename _Tp>
+ struct __add_ref<_Tp&>
+ { typedef _Tp& type; };
+
+ // Adds an rvalue reference to a non-reference type.
+ template<typename _Tp>
+ struct __add_r_ref
+ { typedef _Tp&& type; };
+
+ template<typename _Tp>
+ struct __add_r_ref<_Tp&>
+ { typedef _Tp& type; };
+
+ template<std::size_t _Idx, typename _Head, bool _IsEmptyNotFinal>
+ struct _Head_base;
+
+ template<std::size_t _Idx, typename _Head>
+ struct _Head_base<_Idx, _Head, true>
+ : public _Head
+ {
+ constexpr _Head_base()
+ : _Head() { }
+
+ constexpr _Head_base(const _Head& __h)
+ : _Head(__h) { }
+
+ template<typename _UHead, typename = typename
+ enable_if<!is_convertible<_UHead,
+ __uses_alloc_base>::value>::type>
+ constexpr _Head_base(_UHead&& __h)
+ : _Head(std::forward<_UHead>(__h)) { }
+
+ _Head_base(__uses_alloc0)
+ : _Head() { }
+
+ template<typename _Alloc>
+ _Head_base(__uses_alloc1<_Alloc> __a)
+ : _Head(allocator_arg, *__a._M_a) { }
+
+ template<typename _Alloc>
+ _Head_base(__uses_alloc2<_Alloc> __a)
+ : _Head(*__a._M_a) { }
+
+ template<typename _UHead>
+ _Head_base(__uses_alloc0, _UHead&& __uhead)
+ : _Head(std::forward<_UHead>(__uhead)) { }
+
+ template<typename _Alloc, typename _UHead>
+ _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
+ : _Head(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead)) { }
+
+ template<typename _Alloc, typename _UHead>
+ _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
+ : _Head(std::forward<_UHead>(__uhead), *__a._M_a) { }
+
+ static constexpr _Head&
+ _M_head(_Head_base& __b) noexcept { return __b; }
+
+ static constexpr const _Head&
+ _M_head(const _Head_base& __b) noexcept { return __b; }
+ };
+
+ template<std::size_t _Idx, typename _Head>
+ struct _Head_base<_Idx, _Head, false>
+ {
+ constexpr _Head_base()
+ : _M_head_impl() { }
+
+ constexpr _Head_base(const _Head& __h)
+ : _M_head_impl(__h) { }
+
+ template<typename _UHead, typename = typename
+ enable_if<!is_convertible<_UHead,
+ __uses_alloc_base>::value>::type>
+ constexpr _Head_base(_UHead&& __h)
+ : _M_head_impl(std::forward<_UHead>(__h)) { }
+
+ _Head_base(__uses_alloc0)
+ : _M_head_impl() { }
+
+ template<typename _Alloc>
+ _Head_base(__uses_alloc1<_Alloc> __a)
+ : _M_head_impl(allocator_arg, *__a._M_a) { }
+
+ template<typename _Alloc>
+ _Head_base(__uses_alloc2<_Alloc> __a)
+ : _M_head_impl(*__a._M_a) { }
+
+ template<typename _UHead>
+ _Head_base(__uses_alloc0, _UHead&& __uhead)
+ : _M_head_impl(std::forward<_UHead>(__uhead)) { }
+
+ template<typename _Alloc, typename _UHead>
+ _Head_base(__uses_alloc1<_Alloc> __a, _UHead&& __uhead)
+ : _M_head_impl(allocator_arg, *__a._M_a, std::forward<_UHead>(__uhead))
+ { }
+
+ template<typename _Alloc, typename _UHead>
+ _Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
+ : _M_head_impl(std::forward<_UHead>(__uhead), *__a._M_a) { }
+
+ static constexpr _Head&
+ _M_head(_Head_base& __b) noexcept { return __b._M_head_impl; }
+
+ static constexpr const _Head&
+ _M_head(const _Head_base& __b) noexcept { return __b._M_head_impl; }
+
+ _Head _M_head_impl;
+ };
+
+ /**
+ * Contains the actual implementation of the @c tuple template, stored
+ * as a recursive inheritance hierarchy from the first element (most
+ * derived class) to the last (least derived class). The @c Idx
+ * parameter gives the 0-based index of the element stored at this
+ * point in the hierarchy; we use it to implement a constant-time
+ * get() operation.
+ */
+ template<std::size_t _Idx, typename... _Elements>
+ struct _Tuple_impl;
+
+ /**
+ * Zero-element tuple implementation. This is the basis case for the
+ * inheritance recursion.
+ */
+ template<std::size_t _Idx>
+ struct _Tuple_impl<_Idx>
+ {
+ template<std::size_t, typename...> friend class _Tuple_impl;
+
+ _Tuple_impl() = default;
+
+ template<typename _Alloc>
+ _Tuple_impl(allocator_arg_t, const _Alloc&) { }
+
+ template<typename _Alloc>
+ _Tuple_impl(allocator_arg_t, const _Alloc&, const _Tuple_impl&) { }
+
+ template<typename _Alloc>
+ _Tuple_impl(allocator_arg_t, const _Alloc&, _Tuple_impl&&) { }
+
+ protected:
+ void _M_swap(_Tuple_impl&) noexcept { /* no-op */ }
+ };
+
+ template<typename _Tp>
+ struct __is_empty_non_tuple : is_empty<_Tp> { };
+
+ // Using EBO for elements that are tuples causes ambiguous base errors.
+ template<typename _El0, typename... _El>
+ struct __is_empty_non_tuple<tuple<_El0, _El...>> : false_type { };
+
+ // Use the Empty Base-class Optimization for empty, non-final types.
+ template<typename _Tp>
+ using __empty_not_final
+ = typename conditional<__is_final(_Tp), false_type,
+ __is_empty_non_tuple<_Tp>>::type;
+
+ /**
+ * Recursive tuple implementation. Here we store the @c Head element
+ * and derive from a @c Tuple_impl containing the remaining elements
+ * (which contains the @c Tail).
+ */
+ template<std::size_t _Idx, typename _Head, typename... _Tail>
+ struct _Tuple_impl<_Idx, _Head, _Tail...>
+ : public _Tuple_impl<_Idx + 1, _Tail...>,
+ private _Head_base<_Idx, _Head, __empty_not_final<_Head>::value>
+ {
+ template<std::size_t, typename...> friend class _Tuple_impl;
+
+ typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited;
+ typedef _Head_base<_Idx, _Head, __empty_not_final<_Head>::value> _Base;
+
+ static constexpr _Head&
+ _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
+
+ static constexpr const _Head&
+ _M_head(const _Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
+
+ static constexpr _Inherited&
+ _M_tail(_Tuple_impl& __t) noexcept { return __t; }
+
+ static constexpr const _Inherited&
+ _M_tail(const _Tuple_impl& __t) noexcept { return __t; }
+
+ constexpr _Tuple_impl()
+ : _Inherited(), _Base() { }
+
+ explicit
+ constexpr _Tuple_impl(const _Head& __head, const _Tail&... __tail)
+ : _Inherited(__tail...), _Base(__head) { }
+
+ template<typename _UHead, typename... _UTail, typename = typename
+ enable_if<sizeof...(_Tail) == sizeof...(_UTail)>::type>
+ explicit
+ constexpr _Tuple_impl(_UHead&& __head, _UTail&&... __tail)
+ : _Inherited(std::forward<_UTail>(__tail)...),
+ _Base(std::forward<_UHead>(__head)) { }
+
+ constexpr _Tuple_impl(const _Tuple_impl&) = default;
+
+ constexpr
+ _Tuple_impl(_Tuple_impl&& __in)
+ noexcept(__and_<is_nothrow_move_constructible<_Head>,
+ is_nothrow_move_constructible<_Inherited>>::value)
+ : _Inherited(std::move(_M_tail(__in))),
+ _Base(std::forward<_Head>(_M_head(__in))) { }
+
+ template<typename... _UElements>
+ constexpr _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
+ : _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)),
+ _Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { }
+
+ template<typename _UHead, typename... _UTails>
+ constexpr _Tuple_impl(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
+ : _Inherited(std::move
+ (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
+ _Base(std::forward<_UHead>
+ (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
+
+ template<typename _Alloc>
+ _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a)
+ : _Inherited(__tag, __a),
+ _Base(__use_alloc<_Head>(__a)) { }
+
+ template<typename _Alloc>
+ _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
+ const _Head& __head, const _Tail&... __tail)
+ : _Inherited(__tag, __a, __tail...),
+ _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
+
+ template<typename _Alloc, typename _UHead, typename... _UTail,
+ typename = typename enable_if<sizeof...(_Tail)
+ == sizeof...(_UTail)>::type>
+ _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
+ _UHead&& __head, _UTail&&... __tail)
+ : _Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
+ _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
+ std::forward<_UHead>(__head)) { }
+
+ template<typename _Alloc>
+ _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
+ const _Tuple_impl& __in)
+ : _Inherited(__tag, __a, _M_tail(__in)),
+ _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
+
+ template<typename _Alloc>
+ _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
+ _Tuple_impl&& __in)
+ : _Inherited(__tag, __a, std::move(_M_tail(__in))),
+ _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
+ std::forward<_Head>(_M_head(__in))) { }
+
+ template<typename _Alloc, typename... _UElements>
+ _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
+ const _Tuple_impl<_Idx, _UElements...>& __in)
+ : _Inherited(__tag, __a,
+ _Tuple_impl<_Idx, _UElements...>::_M_tail(__in)),
+ _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
+ _Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { }
+
+ template<typename _Alloc, typename _UHead, typename... _UTails>
+ _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
+ _Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
+ : _Inherited(__tag, __a, std::move
+ (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
+ _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
+ std::forward<_UHead>
+ (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
+
+ _Tuple_impl&
+ operator=(const _Tuple_impl& __in)
+ {
+ _M_head(*this) = _M_head(__in);
+ _M_tail(*this) = _M_tail(__in);
+ return *this;
+ }
+
+ _Tuple_impl&
+ operator=(_Tuple_impl&& __in)
+ noexcept(__and_<is_nothrow_move_assignable<_Head>,
+ is_nothrow_move_assignable<_Inherited>>::value)
+ {
+ _M_head(*this) = std::forward<_Head>(_M_head(__in));
+ _M_tail(*this) = std::move(_M_tail(__in));
+ return *this;
+ }
+
+ template<typename... _UElements>
+ _Tuple_impl&
+ operator=(const _Tuple_impl<_Idx, _UElements...>& __in)
+ {
+ _M_head(*this) = _Tuple_impl<_Idx, _UElements...>::_M_head(__in);
+ _M_tail(*this) = _Tuple_impl<_Idx, _UElements...>::_M_tail(__in);
+ return *this;
+ }
+
+ template<typename _UHead, typename... _UTails>
+ _Tuple_impl&
+ operator=(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
+ {
+ _M_head(*this) = std::forward<_UHead>
+ (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in));
+ _M_tail(*this) = std::move
+ (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in));
+ return *this;
+ }
+
+ protected:
+ void
+ _M_swap(_Tuple_impl& __in)
+ noexcept(noexcept(swap(std::declval<_Head&>(),
+ std::declval<_Head&>()))
+ && noexcept(_M_tail(__in)._M_swap(_M_tail(__in))))
+ {
+ using std::swap;
+ swap(_M_head(*this), _M_head(__in));
+ _Inherited::_M_swap(_M_tail(__in));
+ }
+ };
+
+ /// Primary class template, tuple
+ template<typename... _Elements>
+ class tuple : public _Tuple_impl<0, _Elements...>
+ {
+ typedef _Tuple_impl<0, _Elements...> _Inherited;
+
+ public:
+ constexpr tuple()
+ : _Inherited() { }
+
+ explicit
+ constexpr tuple(const _Elements&... __elements)
+ : _Inherited(__elements...) { }
+
+ template<typename... _UElements, typename = typename
+ enable_if<__and_<is_convertible<_UElements,
+ _Elements>...>::value>::type>
+ explicit
+ constexpr tuple(_UElements&&... __elements)
+ : _Inherited(std::forward<_UElements>(__elements)...) { }
+
+ constexpr tuple(const tuple&) = default;
+
+ constexpr tuple(tuple&&) = default;
+
+ template<typename... _UElements, typename = typename
+ enable_if<__and_<is_convertible<const _UElements&,
+ _Elements>...>::value>::type>
+ constexpr tuple(const tuple<_UElements...>& __in)
+ : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
+ { }
+
+ template<typename... _UElements, typename = typename
+ enable_if<__and_<is_convertible<_UElements,
+ _Elements>...>::value>::type>
+ constexpr tuple(tuple<_UElements...>&& __in)
+ : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
+
+ // Allocator-extended constructors.
+
+ template<typename _Alloc>
+ tuple(allocator_arg_t __tag, const _Alloc& __a)
+ : _Inherited(__tag, __a) { }
+
+ template<typename _Alloc>
+ tuple(allocator_arg_t __tag, const _Alloc& __a,
+ const _Elements&... __elements)
+ : _Inherited(__tag, __a, __elements...) { }
+
+ template<typename _Alloc, typename... _UElements, typename = typename
+ enable_if<sizeof...(_UElements)
+ == sizeof...(_Elements)>::type>
+ tuple(allocator_arg_t __tag, const _Alloc& __a,
+ _UElements&&... __elements)
+ : _Inherited(__tag, __a, std::forward<_UElements>(__elements)...)
+ { }
+
+ template<typename _Alloc>
+ tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
+ : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
+
+ template<typename _Alloc>
+ tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
+ : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
+
+ template<typename _Alloc, typename... _UElements, typename = typename
+ enable_if<sizeof...(_UElements)
+ == sizeof...(_Elements)>::type>
+ tuple(allocator_arg_t __tag, const _Alloc& __a,
+ const tuple<_UElements...>& __in)
+ : _Inherited(__tag, __a,
+ static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
+ { }
+
+ template<typename _Alloc, typename... _UElements, typename = typename
+ enable_if<sizeof...(_UElements)
+ == sizeof...(_Elements)>::type>
+ tuple(allocator_arg_t __tag, const _Alloc& __a,
+ tuple<_UElements...>&& __in)
+ : _Inherited(__tag, __a,
+ static_cast<_Tuple_impl<0, _UElements...>&&>(__in))
+ { }
+
+ tuple&
+ operator=(const tuple& __in)
+ {
+ static_cast<_Inherited&>(*this) = __in;
+ return *this;
+ }
+
+ tuple&
+ operator=(tuple&& __in)
+ noexcept(is_nothrow_move_assignable<_Inherited>::value)
+ {
+ static_cast<_Inherited&>(*this) = std::move(__in);
+ return *this;
+ }
+
+ template<typename... _UElements, typename = typename
+ enable_if<sizeof...(_UElements)
+ == sizeof...(_Elements)>::type>
+ tuple&
+ operator=(const tuple<_UElements...>& __in)
+ {
+ static_cast<_Inherited&>(*this) = __in;
+ return *this;
+ }
+
+ template<typename... _UElements, typename = typename
+ enable_if<sizeof...(_UElements)
+ == sizeof...(_Elements)>::type>
+ tuple&
+ operator=(tuple<_UElements...>&& __in)
+ {
+ static_cast<_Inherited&>(*this) = std::move(__in);
+ return *this;
+ }
+
+ void
+ swap(tuple& __in)
+ noexcept(noexcept(__in._M_swap(__in)))
+ { _Inherited::_M_swap(__in); }
+ };
+
+ // Explicit specialization, zero-element tuple.
+ template<>
+ class tuple<>
+ {
+ public:
+ void swap(tuple&) noexcept { /* no-op */ }
+ };
+
+ /// Partial specialization, 2-element tuple.
+ /// Includes construction and assignment from a pair.
+ template<typename _T1, typename _T2>
+ class tuple<_T1, _T2> : public _Tuple_impl<0, _T1, _T2>
+ {
+ typedef _Tuple_impl<0, _T1, _T2> _Inherited;
+
+ public:
+ constexpr tuple()
+ : _Inherited() { }
+
+ explicit
+ constexpr tuple(const _T1& __a1, const _T2& __a2)
+ : _Inherited(__a1, __a2) { }
+
+ template<typename _U1, typename _U2, typename = typename
+ enable_if<__and_<is_convertible<_U1, _T1>,
+ is_convertible<_U2, _T2>>::value>::type>
+ explicit
+ constexpr tuple(_U1&& __a1, _U2&& __a2)
+ : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { }
+
+ constexpr tuple(const tuple&) = default;
+
+ constexpr tuple(tuple&&) = default;
+
+ template<typename _U1, typename _U2, typename = typename
+ enable_if<__and_<is_convertible<const _U1&, _T1>,
+ is_convertible<const _U2&, _T2>>::value>::type>
+ constexpr tuple(const tuple<_U1, _U2>& __in)
+ : _Inherited(static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in)) { }
+
+ template<typename _U1, typename _U2, typename = typename
+ enable_if<__and_<is_convertible<_U1, _T1>,
+ is_convertible<_U2, _T2>>::value>::type>
+ constexpr tuple(tuple<_U1, _U2>&& __in)
+ : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { }
+
+ template<typename _U1, typename _U2, typename = typename
+ enable_if<__and_<is_convertible<const _U1&, _T1>,
+ is_convertible<const _U2&, _T2>>::value>::type>
+ constexpr tuple(const pair<_U1, _U2>& __in)
+ : _Inherited(__in.first, __in.second) { }
+
+ template<typename _U1, typename _U2, typename = typename
+ enable_if<__and_<is_convertible<_U1, _T1>,
+ is_convertible<_U2, _T2>>::value>::type>
+ constexpr tuple(pair<_U1, _U2>&& __in)
+ : _Inherited(std::forward<_U1>(__in.first),
+ std::forward<_U2>(__in.second)) { }
+
+ // Allocator-extended constructors.
+
+ template<typename _Alloc>
+ tuple(allocator_arg_t __tag, const _Alloc& __a)
+ : _Inherited(__tag, __a) { }
+
+ template<typename _Alloc>
+ tuple(allocator_arg_t __tag, const _Alloc& __a,
+ const _T1& __a1, const _T2& __a2)
+ : _Inherited(__tag, __a, __a1, __a2) { }
+
+ template<typename _Alloc, typename _U1, typename _U2>
+ tuple(allocator_arg_t __tag, const _Alloc& __a, _U1&& __a1, _U2&& __a2)
+ : _Inherited(__tag, __a, std::forward<_U1>(__a1),
+ std::forward<_U2>(__a2)) { }
+
+ template<typename _Alloc>
+ tuple(allocator_arg_t __tag, const _Alloc& __a, const tuple& __in)
+ : _Inherited(__tag, __a, static_cast<const _Inherited&>(__in)) { }
+
+ template<typename _Alloc>
+ tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in)
+ : _Inherited(__tag, __a, static_cast<_Inherited&&>(__in)) { }
+
+ template<typename _Alloc, typename _U1, typename _U2>
+ tuple(allocator_arg_t __tag, const _Alloc& __a,
+ const tuple<_U1, _U2>& __in)
+ : _Inherited(__tag, __a,
+ static_cast<const _Tuple_impl<0, _U1, _U2>&>(__in))
+ { }
+
+ template<typename _Alloc, typename _U1, typename _U2>
+ tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in)
+ : _Inherited(__tag, __a, static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in))
+ { }
+
+ template<typename _Alloc, typename _U1, typename _U2>
+ tuple(allocator_arg_t __tag, const _Alloc& __a,
+ const pair<_U1, _U2>& __in)
+ : _Inherited(__tag, __a, __in.first, __in.second) { }
+
+ template<typename _Alloc, typename _U1, typename _U2>
+ tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in)
+ : _Inherited(__tag, __a, std::forward<_U1>(__in.first),
+ std::forward<_U2>(__in.second)) { }
+
+ tuple&
+ operator=(const tuple& __in)
+ {
+ static_cast<_Inherited&>(*this) = __in;
+ return *this;
+ }
+
+ tuple&
+ operator=(tuple&& __in)
+ noexcept(is_nothrow_move_assignable<_Inherited>::value)
+ {
+ static_cast<_Inherited&>(*this) = std::move(__in);
+ return *this;
+ }
+
+ template<typename _U1, typename _U2>
+ tuple&
+ operator=(const tuple<_U1, _U2>& __in)
+ {
+ static_cast<_Inherited&>(*this) = __in;
+ return *this;
+ }
+
+ template<typename _U1, typename _U2>
+ tuple&
+ operator=(tuple<_U1, _U2>&& __in)
+ {
+ static_cast<_Inherited&>(*this) = std::move(__in);
+ return *this;
+ }
+
+ template<typename _U1, typename _U2>
+ tuple&
+ operator=(const pair<_U1, _U2>& __in)
+ {
+ this->_M_head(*this) = __in.first;
+ this->_M_tail(*this)._M_head(*this) = __in.second;
+ return *this;
+ }
+
+ template<typename _U1, typename _U2>
+ tuple&
+ operator=(pair<_U1, _U2>&& __in)
+ {
+ this->_M_head(*this) = std::forward<_U1>(__in.first);
+ this->_M_tail(*this)._M_head(*this) = std::forward<_U2>(__in.second);
+ return *this;
+ }
+
+ void
+ swap(tuple& __in)
+ noexcept(noexcept(__in._M_swap(__in)))
+ { _Inherited::_M_swap(__in); }
+ };
+
+
+ /// Gives the type of the ith element of a given tuple type.
+ template<std::size_t __i, typename _Tp>
+ struct tuple_element;
+
+ /**
+ * Recursive case for tuple_element: strip off the first element in
+ * the tuple and retrieve the (i-1)th element of the remaining tuple.
+ */
+ template<std::size_t __i, typename _Head, typename... _Tail>
+ struct tuple_element<__i, tuple<_Head, _Tail...> >
+ : tuple_element<__i - 1, tuple<_Tail...> > { };
+
+ /**
+ * Basis case for tuple_element: The first element is the one we're seeking.
+ */
+ template<typename _Head, typename... _Tail>
+ struct tuple_element<0, tuple<_Head, _Tail...> >
+ {
+ typedef _Head type;
+ };
+
+ template<std::size_t __i, typename _Tp>
+ struct tuple_element<__i, const _Tp>
+ {
+ typedef typename
+ add_const<typename tuple_element<__i, _Tp>::type>::type type;
+ };
+
+ template<std::size_t __i, typename _Tp>
+ struct tuple_element<__i, volatile _Tp>
+ {
+ typedef typename
+ add_volatile<typename tuple_element<__i, _Tp>::type>::type type;
+ };
+
+ template<std::size_t __i, typename _Tp>
+ struct tuple_element<__i, const volatile _Tp>
+ {
+ typedef typename
+ add_cv<typename tuple_element<__i, _Tp>::type>::type type;
+ };
+
+ /// Finds the size of a given tuple type.
+ template<typename _Tp>
+ struct tuple_size;
+
+ template<typename _Tp>
+ struct tuple_size<const _Tp>
+ : public integral_constant<
+ typename remove_cv<decltype(tuple_size<_Tp>::value)>::type,
+ tuple_size<_Tp>::value> { };
+
+ template<typename _Tp>
+ struct tuple_size<volatile _Tp>
+ : public integral_constant<
+ typename remove_cv<decltype(tuple_size<_Tp>::value)>::type,
+ tuple_size<_Tp>::value> { };
+
+ template<typename _Tp>
+ struct tuple_size<const volatile _Tp>
+ : public integral_constant<
+ typename remove_cv<decltype(tuple_size<_Tp>::value)>::type,
+ tuple_size<_Tp>::value> { };
+
+ /// class tuple_size
+ template<typename... _Elements>
+ struct tuple_size<tuple<_Elements...>>
+ : public integral_constant<std::size_t, sizeof...(_Elements)> { };
+
+ template<std::size_t __i, typename _Head, typename... _Tail>
+ constexpr typename __add_ref<_Head>::type
+ __get_helper(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
+ { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
+
+ template<std::size_t __i, typename _Head, typename... _Tail>
+ constexpr typename __add_c_ref<_Head>::type
+ __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
+ { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
+
+ // Return a reference (const reference, rvalue reference) to the ith element
+ // of a tuple. Any const or non-const ref elements are returned with their
+ // original type.
+ template<std::size_t __i, typename... _Elements>
+ constexpr typename __add_ref<
+ typename tuple_element<__i, tuple<_Elements...>>::type
+ >::type
+ get(tuple<_Elements...>& __t) noexcept
+ { return __get_helper<__i>(__t); }
+
+ template<std::size_t __i, typename... _Elements>
+ constexpr typename __add_c_ref<
+ typename tuple_element<__i, tuple<_Elements...>>::type
+ >::type
+ get(const tuple<_Elements...>& __t) noexcept
+ { return __get_helper<__i>(__t); }
+
+ template<std::size_t __i, typename... _Elements>
+ constexpr typename __add_r_ref<
+ typename tuple_element<__i, tuple<_Elements...>>::type
+ >::type
+ get(tuple<_Elements...>&& __t) noexcept
+ { return std::forward<typename tuple_element<__i,
+ tuple<_Elements...>>::type&&>(get<__i>(__t)); }
+
+#if __cplusplus > 201103L
+ template<typename _Head, size_t __i, typename... _Tail>
+ constexpr typename __add_ref<_Head>::type
+ __get_helper2(_Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
+ { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
+
+ template<typename _Head, size_t __i, typename... _Tail>
+ constexpr typename __add_c_ref<_Head>::type
+ __get_helper2(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
+ { return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
+
+ template <typename _Tp, typename... _Types>
+ constexpr _Tp&
+ get(tuple<_Types...>& __t) noexcept
+ { return __get_helper2<_Tp>(__t); }
+
+ template <typename _Tp, typename... _Types>
+ constexpr _Tp&&
+ get(tuple<_Types...>&& __t) noexcept
+ { return std::move(__get_helper2<_Tp>(__t)); }
+
+ template <typename _Tp, typename... _Types>
+ constexpr const _Tp&
+ get(const tuple<_Types...>& __t) noexcept
+ { return __get_helper2<_Tp>(__t); }
+#endif
+
+ // This class helps construct the various comparison operations on tuples
+ template<std::size_t __check_equal_size, std::size_t __i, std::size_t __j,
+ typename _Tp, typename _Up>
+ struct __tuple_compare;
+
+ template<std::size_t __i, std::size_t __j, typename _Tp, typename _Up>
+ struct __tuple_compare<0, __i, __j, _Tp, _Up>
+ {
+ static constexpr bool
+ __eq(const _Tp& __t, const _Up& __u)
+ {
+ return (get<__i>(__t) == get<__i>(__u) &&
+ __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__eq(__t, __u));
+ }
+
+ static constexpr bool
+ __less(const _Tp& __t, const _Up& __u)
+ {
+ return ((get<__i>(__t) < get<__i>(__u))
+ || !(get<__i>(__u) < get<__i>(__t)) &&
+ __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__less(__t, __u));
+ }
+ };
+
+ template<std::size_t __i, typename _Tp, typename _Up>
+ struct __tuple_compare<0, __i, __i, _Tp, _Up>
+ {
+ static constexpr bool
+ __eq(const _Tp&, const _Up&) { return true; }
+
+ static constexpr bool
+ __less(const _Tp&, const _Up&) { return false; }
+ };
+
+ template<typename... _TElements, typename... _UElements>
+ constexpr bool
+ operator==(const tuple<_TElements...>& __t,
+ const tuple<_UElements...>& __u)
+ {
+ typedef tuple<_TElements...> _Tp;
+ typedef tuple<_UElements...> _Up;
+ return bool(__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value,
+ 0, tuple_size<_Tp>::value, _Tp, _Up>::__eq(__t, __u));
+ }
+
+ template<typename... _TElements, typename... _UElements>
+ constexpr bool
+ operator<(const tuple<_TElements...>& __t,
+ const tuple<_UElements...>& __u)
+ {
+ typedef tuple<_TElements...> _Tp;
+ typedef tuple<_UElements...> _Up;
+ return bool(__tuple_compare<tuple_size<_Tp>::value - tuple_size<_Up>::value,
+ 0, tuple_size<_Tp>::value, _Tp, _Up>::__less(__t, __u));
+ }
+
+ template<typename... _TElements, typename... _UElements>
+ constexpr bool
+ operator!=(const tuple<_TElements...>& __t,
+ const tuple<_UElements...>& __u)
+ { return !(__t == __u); }
+
+ template<typename... _TElements, typename... _UElements>
+ constexpr bool
+ operator>(const tuple<_TElements...>& __t,
+ const tuple<_UElements...>& __u)
+ { return __u < __t; }
+
+ template<typename... _TElements, typename... _UElements>
+ constexpr bool
+ operator<=(const tuple<_TElements...>& __t,
+ const tuple<_UElements...>& __u)
+ { return !(__u < __t); }
+
+ template<typename... _TElements, typename... _UElements>
+ constexpr bool
+ operator>=(const tuple<_TElements...>& __t,
+ const tuple<_UElements...>& __u)
+ { return !(__t < __u); }
+
+ // NB: DR 705.
+ template<typename... _Elements>
+ constexpr tuple<typename __decay_and_strip<_Elements>::__type...>
+ make_tuple(_Elements&&... __args)
+ {
+ typedef tuple<typename __decay_and_strip<_Elements>::__type...>
+ __result_type;
+ return __result_type(std::forward<_Elements>(__args)...);
+ }
+
+ template<typename... _Elements>
+ tuple<_Elements&&...>
+ forward_as_tuple(_Elements&&... __args) noexcept
+ { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
+
+ template<typename>
+ struct __is_tuple_like_impl : false_type
+ { };
+
+ template<typename... _Tps>
+ struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
+ { };
+
+ template<typename _T1, typename _T2>
+ struct __is_tuple_like_impl<pair<_T1, _T2>> : true_type
+ { };
+
+ template<typename _Tp, std::size_t _Nm>
+ struct __is_tuple_like_impl<array<_Tp, _Nm>> : true_type
+ { };
+
+ // Internal type trait that allows us to sfinae-protect tuple_cat.
+ template<typename _Tp>
+ struct __is_tuple_like
+ : public __is_tuple_like_impl<typename std::remove_cv
+ <typename std::remove_reference<_Tp>::type>::type>::type
+ { };
+
+ template<std::size_t, typename, typename, std::size_t>
+ struct __make_tuple_impl;
+
+ template<std::size_t _Idx, typename _Tuple, typename... _Tp,
+ std::size_t _Nm>
+ struct __make_tuple_impl<_Idx, tuple<_Tp...>, _Tuple, _Nm>
+ {
+ typedef typename __make_tuple_impl<_Idx + 1, tuple<_Tp...,
+ typename std::tuple_element<_Idx, _Tuple>::type>, _Tuple, _Nm>::__type
+ __type;
+ };
+
+ template<std::size_t _Nm, typename _Tuple, typename... _Tp>
+ struct __make_tuple_impl<_Nm, tuple<_Tp...>, _Tuple, _Nm>
+ {
+ typedef tuple<_Tp...> __type;
+ };
+
+ template<typename _Tuple>
+ struct __do_make_tuple
+ : public __make_tuple_impl<0, tuple<>, _Tuple,
+ std::tuple_size<_Tuple>::value>
+ { };
+
+ // Returns the std::tuple equivalent of a tuple-like type.
+ template<typename _Tuple>
+ struct __make_tuple
+ : public __do_make_tuple<typename std::remove_cv
+ <typename std::remove_reference<_Tuple>::type>::type>
+ { };
+
+ // Combines several std::tuple's into a single one.
+ template<typename...>
+ struct __combine_tuples;
+
+ template<>
+ struct __combine_tuples<>
+ {
+ typedef tuple<> __type;
+ };
+
+ template<typename... _Ts>
+ struct __combine_tuples<tuple<_Ts...>>
+ {
+ typedef tuple<_Ts...> __type;
+ };
+
+ template<typename... _T1s, typename... _T2s, typename... _Rem>
+ struct __combine_tuples<tuple<_T1s...>, tuple<_T2s...>, _Rem...>
+ {
+ typedef typename __combine_tuples<tuple<_T1s..., _T2s...>,
+ _Rem...>::__type __type;
+ };
+
+ // Computes the result type of tuple_cat given a set of tuple-like types.
+ template<typename... _Tpls>
+ struct __tuple_cat_result
+ {
+ typedef typename __combine_tuples
+ <typename __make_tuple<_Tpls>::__type...>::__type __type;
+ };
+
+ // Helper to determine the index set for the first tuple-like
+ // type of a given set.
+ template<typename...>
+ struct __make_1st_indices;
+
+ template<>
+ struct __make_1st_indices<>
+ {
+ typedef std::_Index_tuple<> __type;
+ };
+
+ template<typename _Tp, typename... _Tpls>
+ struct __make_1st_indices<_Tp, _Tpls...>
+ {
+ typedef typename std::_Build_index_tuple<std::tuple_size<
+ typename std::remove_reference<_Tp>::type>::value>::__type __type;
+ };
+
+ // Performs the actual concatenation by step-wise expanding tuple-like
+ // objects into the elements, which are finally forwarded into the
+ // result tuple.
+ template<typename _Ret, typename _Indices, typename... _Tpls>
+ struct __tuple_concater;
+
+ template<typename _Ret, std::size_t... _Is, typename _Tp, typename... _Tpls>
+ struct __tuple_concater<_Ret, std::_Index_tuple<_Is...>, _Tp, _Tpls...>
+ {
+ template<typename... _Us>
+ static constexpr _Ret
+ _S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)
+ {
+ typedef typename __make_1st_indices<_Tpls...>::__type __idx;
+ typedef __tuple_concater<_Ret, __idx, _Tpls...> __next;
+ return __next::_S_do(std::forward<_Tpls>(__tps)...,
+ std::forward<_Us>(__us)...,
+ std::get<_Is>(std::forward<_Tp>(__tp))...);
+ }
+ };
+
+ template<typename _Ret>
+ struct __tuple_concater<_Ret, std::_Index_tuple<>>
+ {
+ template<typename... _Us>
+ static constexpr _Ret
+ _S_do(_Us&&... __us)
+ {
+ return _Ret(std::forward<_Us>(__us)...);
+ }
+ };
+
+ /// tuple_cat
+ template<typename... _Tpls, typename = typename
+ enable_if<__and_<__is_tuple_like<_Tpls>...>::value>::type>
+ constexpr auto
+ tuple_cat(_Tpls&&... __tpls)
+ -> typename __tuple_cat_result<_Tpls...>::__type
+ {
+ typedef typename __tuple_cat_result<_Tpls...>::__type __ret;
+ typedef typename __make_1st_indices<_Tpls...>::__type __idx;
+ typedef __tuple_concater<__ret, __idx, _Tpls...> __concater;
+ return __concater::_S_do(std::forward<_Tpls>(__tpls)...);
+ }
+
+ /// tie
+ template<typename... _Elements>
+ inline tuple<_Elements&...>
+ tie(_Elements&... __args) noexcept
+ { return tuple<_Elements&...>(__args...); }
+
+ /// swap
+ template<typename... _Elements>
+ inline void
+ swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y)
+ noexcept(noexcept(__x.swap(__y)))
+ { __x.swap(__y); }
+
+ // A class (and instance) which can be used in 'tie' when an element
+ // of a tuple is not required
+ struct _Swallow_assign
+ {
+ template<class _Tp>
+ const _Swallow_assign&
+ operator=(const _Tp&) const
+ { return *this; }
+ };
+
+ const _Swallow_assign ignore{};
+
+ /// Partial specialization for tuples
+ template<typename... _Types, typename _Alloc>
+ struct uses_allocator<tuple<_Types...>, _Alloc> : true_type { };
+
+ // See stl_pair.h...
+ template<class _T1, class _T2>
+ template<typename... _Args1, typename... _Args2>
+ inline
+ pair<_T1, _T2>::
+ pair(piecewise_construct_t,
+ tuple<_Args1...> __first, tuple<_Args2...> __second)
+ : pair(__first, __second,
+ typename _Build_index_tuple<sizeof...(_Args1)>::__type(),
+ typename _Build_index_tuple<sizeof...(_Args2)>::__type())
+ { }
+
+ template<class _T1, class _T2>
+ template<typename... _Args1, std::size_t... _Indexes1,
+ typename... _Args2, std::size_t... _Indexes2>
+ inline
+ pair<_T1, _T2>::
+ pair(tuple<_Args1...>& __tuple1, tuple<_Args2...>& __tuple2,
+ _Index_tuple<_Indexes1...>, _Index_tuple<_Indexes2...>)
+ : first(std::forward<_Args1>(std::get<_Indexes1>(__tuple1))...),
+ second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
+ { }
+
+ /// @}
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+
+#endif // C++11
+
+#endif // _GLIBCXX_TUPLE
diff --git a/gcc-4.9/libstdc++-v3/include/std/type_traits b/gcc-4.9/libstdc++-v3/include/std/type_traits
new file mode 100644
index 0000000..4b434a6
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/type_traits
@@ -0,0 +1,2236 @@
+// C++11 <type_traits> -*- C++ -*-
+
+// Copyright (C) 2007-2014 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/type_traits
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_TYPE_TRAITS
+#define _GLIBCXX_TYPE_TRAITS 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <bits/c++config.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @defgroup metaprogramming Metaprogramming
+ * @ingroup utilities
+ *
+ * Template utilities for compile-time introspection and modification,
+ * including type classification traits, type property inspection traits
+ * and type transformation traits.
+ *
+ * @{
+ */
+
+ /// integral_constant
+ template<typename _Tp, _Tp __v>
+ struct integral_constant
+ {
+ static constexpr _Tp value = __v;
+ typedef _Tp value_type;
+ typedef integral_constant<_Tp, __v> type;
+ constexpr operator value_type() const { return value; }
+#if __cplusplus > 201103L
+ constexpr value_type operator()() const { return value; }
+#endif
+ };
+
+ template<typename _Tp, _Tp __v>
+ constexpr _Tp integral_constant<_Tp, __v>::value;
+
+ /// The type used as a compile-time boolean with true value.
+ typedef integral_constant<bool, true> true_type;
+
+ /// The type used as a compile-time boolean with false value.
+ typedef integral_constant<bool, false> false_type;
+
+ // Meta programming helper types.
+
+ template<bool, typename, typename>
+ struct conditional;
+
+ template<typename...>
+ struct __or_;
+
+ template<>
+ struct __or_<>
+ : public false_type
+ { };
+
+ template<typename _B1>
+ struct __or_<_B1>
+ : public _B1
+ { };
+
+ template<typename _B1, typename _B2>
+ struct __or_<_B1, _B2>
+ : public conditional<_B1::value, _B1, _B2>::type
+ { };
+
+ template<typename _B1, typename _B2, typename _B3, typename... _Bn>
+ struct __or_<_B1, _B2, _B3, _Bn...>
+ : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
+ { };
+
+ template<typename...>
+ struct __and_;
+
+ template<>
+ struct __and_<>
+ : public true_type
+ { };
+
+ template<typename _B1>
+ struct __and_<_B1>
+ : public _B1
+ { };
+
+ template<typename _B1, typename _B2>
+ struct __and_<_B1, _B2>
+ : public conditional<_B1::value, _B2, _B1>::type
+ { };
+
+ template<typename _B1, typename _B2, typename _B3, typename... _Bn>
+ struct __and_<_B1, _B2, _B3, _Bn...>
+ : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type
+ { };
+
+ template<typename _Pp>
+ struct __not_
+ : public integral_constant<bool, !_Pp::value>
+ { };
+
+ // For several sfinae-friendly trait implementations we transport both the
+ // result information (as the member type) and the failure information (no
+ // member type). This is very similar to std::enable_if, but we cannot use
+ // them, because we need to derive from them as an implementation detail.
+
+ template<typename _Tp>
+ struct __success_type
+ { typedef _Tp type; };
+
+ struct __failure_type
+ { };
+
+ // Primary type categories.
+
+ template<typename>
+ struct remove_cv;
+
+ template<typename>
+ struct __is_void_helper
+ : public false_type { };
+
+ template<>
+ struct __is_void_helper<void>
+ : public true_type { };
+
+ /// is_void
+ template<typename _Tp>
+ struct is_void
+ : public __is_void_helper<typename remove_cv<_Tp>::type>::type
+ { };
+
+ template<typename>
+ struct __is_integral_helper
+ : public false_type { };
+
+ template<>
+ struct __is_integral_helper<bool>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<char>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<signed char>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<unsigned char>
+ : public true_type { };
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template<>
+ struct __is_integral_helper<wchar_t>
+ : public true_type { };
+#endif
+
+ template<>
+ struct __is_integral_helper<char16_t>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<char32_t>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<short>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<unsigned short>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<int>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<unsigned int>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<long>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<unsigned long>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<long long>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<unsigned long long>
+ : public true_type { };
+
+#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
+ template<>
+ struct __is_integral_helper<__int128>
+ : public true_type { };
+
+ template<>
+ struct __is_integral_helper<unsigned __int128>
+ : public true_type { };
+#endif
+
+ /// is_integral
+ template<typename _Tp>
+ struct is_integral
+ : public __is_integral_helper<typename remove_cv<_Tp>::type>::type
+ { };
+
+ template<typename>
+ struct __is_floating_point_helper
+ : public false_type { };
+
+ template<>
+ struct __is_floating_point_helper<float>
+ : public true_type { };
+
+ template<>
+ struct __is_floating_point_helper<double>
+ : public true_type { };
+
+ template<>
+ struct __is_floating_point_helper<long double>
+ : public true_type { };
+
+#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
+ template<>
+ struct __is_floating_point_helper<__float128>
+ : public true_type { };
+#endif
+
+ /// is_floating_point
+ template<typename _Tp>
+ struct is_floating_point
+ : public __is_floating_point_helper<typename remove_cv<_Tp>::type>::type
+ { };
+
+ /// is_array
+ template<typename>
+ struct is_array
+ : public false_type { };
+
+ template<typename _Tp, std::size_t _Size>
+ struct is_array<_Tp[_Size]>
+ : public true_type { };
+
+ template<typename _Tp>
+ struct is_array<_Tp[]>
+ : public true_type { };
+
+ template<typename>
+ struct __is_pointer_helper
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_pointer_helper<_Tp*>
+ : public true_type { };
+
+ /// is_pointer
+ template<typename _Tp>
+ struct is_pointer
+ : public __is_pointer_helper<typename remove_cv<_Tp>::type>::type
+ { };
+
+ /// is_lvalue_reference
+ template<typename>
+ struct is_lvalue_reference
+ : public false_type { };
+
+ template<typename _Tp>
+ struct is_lvalue_reference<_Tp&>
+ : public true_type { };
+
+ /// is_rvalue_reference
+ template<typename>
+ struct is_rvalue_reference
+ : public false_type { };
+
+ template<typename _Tp>
+ struct is_rvalue_reference<_Tp&&>
+ : public true_type { };
+
+ template<typename>
+ struct is_function;
+
+ template<typename>
+ struct __is_member_object_pointer_helper
+ : public false_type { };
+
+ template<typename _Tp, typename _Cp>
+ struct __is_member_object_pointer_helper<_Tp _Cp::*>
+ : public integral_constant<bool, !is_function<_Tp>::value> { };
+
+ /// is_member_object_pointer
+ template<typename _Tp>
+ struct is_member_object_pointer
+ : public __is_member_object_pointer_helper<
+ typename remove_cv<_Tp>::type>::type
+ { };
+
+ template<typename>
+ struct __is_member_function_pointer_helper
+ : public false_type { };
+
+ template<typename _Tp, typename _Cp>
+ struct __is_member_function_pointer_helper<_Tp _Cp::*>
+ : public integral_constant<bool, is_function<_Tp>::value> { };
+
+ /// is_member_function_pointer
+ template<typename _Tp>
+ struct is_member_function_pointer
+ : public __is_member_function_pointer_helper<
+ typename remove_cv<_Tp>::type>::type
+ { };
+
+ /// is_enum
+ template<typename _Tp>
+ struct is_enum
+ : public integral_constant<bool, __is_enum(_Tp)>
+ { };
+
+ /// is_union
+ template<typename _Tp>
+ struct is_union
+ : public integral_constant<bool, __is_union(_Tp)>
+ { };
+
+ /// is_class
+ template<typename _Tp>
+ struct is_class
+ : public integral_constant<bool, __is_class(_Tp)>
+ { };
+
+ /// is_function
+ template<typename>
+ struct is_function
+ : public false_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...)>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) &>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) &&>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......)>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) &>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) &&>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) const>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) const &>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) const &&>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) const>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) const &>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) const &&>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) volatile>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) volatile &>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) volatile &&>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) volatile>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) volatile &>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) volatile &&>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) const volatile>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) const volatile &>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes...) const volatile &&>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) const volatile>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) const volatile &>
+ : public true_type { };
+
+ template<typename _Res, typename... _ArgTypes>
+ struct is_function<_Res(_ArgTypes......) const volatile &&>
+ : public true_type { };
+
+ template<typename>
+ struct __is_null_pointer_helper
+ : public false_type { };
+
+ template<>
+ struct __is_null_pointer_helper<std::nullptr_t>
+ : public true_type { };
+
+ /// is_null_pointer (LWG 2247).
+ template<typename _Tp>
+ struct is_null_pointer
+ : public __is_null_pointer_helper<typename remove_cv<_Tp>::type>::type
+ { };
+
+ /// __is_nullptr_t (extension).
+ template<typename _Tp>
+ struct __is_nullptr_t
+ : public is_null_pointer<_Tp>
+ { };
+
+ // Composite type categories.
+
+ /// is_reference
+ template<typename _Tp>
+ struct is_reference
+ : public __or_<is_lvalue_reference<_Tp>,
+ is_rvalue_reference<_Tp>>::type
+ { };
+
+ /// is_arithmetic
+ template<typename _Tp>
+ struct is_arithmetic
+ : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type
+ { };
+
+ /// is_fundamental
+ template<typename _Tp>
+ struct is_fundamental
+ : public __or_<is_arithmetic<_Tp>, is_void<_Tp>,
+ is_null_pointer<_Tp>>::type
+ { };
+
+ /// is_object
+ template<typename _Tp>
+ struct is_object
+ : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
+ is_void<_Tp>>>::type
+ { };
+
+ template<typename>
+ struct is_member_pointer;
+
+ /// is_scalar
+ template<typename _Tp>
+ struct is_scalar
+ : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
+ is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
+ { };
+
+ /// is_compound
+ template<typename _Tp>
+ struct is_compound
+ : public integral_constant<bool, !is_fundamental<_Tp>::value> { };
+
+ template<typename _Tp>
+ struct __is_member_pointer_helper
+ : public false_type { };
+
+ template<typename _Tp, typename _Cp>
+ struct __is_member_pointer_helper<_Tp _Cp::*>
+ : public true_type { };
+
+ /// is_member_pointer
+ template<typename _Tp>
+ struct is_member_pointer
+ : public __is_member_pointer_helper<typename remove_cv<_Tp>::type>::type
+ { };
+
+ // Utility to detect referenceable types ([defns.referenceable]).
+
+ template<typename _Tp>
+ struct __is_referenceable
+ : public __or_<is_object<_Tp>, is_reference<_Tp>>::type
+ { };
+
+ template<typename _Res, typename... _Args>
+ struct __is_referenceable<_Res(_Args...)>
+ : public true_type
+ { };
+
+ template<typename _Res, typename... _Args>
+ struct __is_referenceable<_Res(_Args......)>
+ : public true_type
+ { };
+
+ // Type properties.
+
+ /// is_const
+ template<typename>
+ struct is_const
+ : public false_type { };
+
+ template<typename _Tp>
+ struct is_const<_Tp const>
+ : public true_type { };
+
+ /// is_volatile
+ template<typename>
+ struct is_volatile
+ : public false_type { };
+
+ template<typename _Tp>
+ struct is_volatile<_Tp volatile>
+ : public true_type { };
+
+ /// is_trivial
+ template<typename _Tp>
+ struct is_trivial
+ : public integral_constant<bool, __is_trivial(_Tp)>
+ { };
+
+ // is_trivially_copyable (still unimplemented)
+
+ /// is_standard_layout
+ template<typename _Tp>
+ struct is_standard_layout
+ : public integral_constant<bool, __is_standard_layout(_Tp)>
+ { };
+
+ /// is_pod
+ // Could use is_standard_layout && is_trivial instead of the builtin.
+ template<typename _Tp>
+ struct is_pod
+ : public integral_constant<bool, __is_pod(_Tp)>
+ { };
+
+ /// is_literal_type
+ template<typename _Tp>
+ struct is_literal_type
+ : public integral_constant<bool, __is_literal_type(_Tp)>
+ { };
+
+ /// is_empty
+ template<typename _Tp>
+ struct is_empty
+ : public integral_constant<bool, __is_empty(_Tp)>
+ { };
+
+ /// is_polymorphic
+ template<typename _Tp>
+ struct is_polymorphic
+ : public integral_constant<bool, __is_polymorphic(_Tp)>
+ { };
+
+ /// is_abstract
+ template<typename _Tp>
+ struct is_abstract
+ : public integral_constant<bool, __is_abstract(_Tp)>
+ { };
+
+ template<typename _Tp,
+ bool = is_arithmetic<_Tp>::value>
+ struct __is_signed_helper
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_signed_helper<_Tp, true>
+ : public integral_constant<bool, _Tp(-1) < _Tp(0)>
+ { };
+
+ /// is_signed
+ template<typename _Tp>
+ struct is_signed
+ : public __is_signed_helper<_Tp>::type
+ { };
+
+ /// is_unsigned
+ template<typename _Tp>
+ struct is_unsigned
+ : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>::type
+ { };
+
+
+ // Destructible and constructible type properties.
+
+ template<typename>
+ struct add_rvalue_reference;
+
+ /**
+ * @brief Utility to simplify expressions used in unevaluated operands
+ * @ingroup utilities
+ */
+ template<typename _Tp>
+ typename add_rvalue_reference<_Tp>::type declval() noexcept;
+
+ template<typename, unsigned = 0>
+ struct extent;
+
+ template<typename>
+ struct remove_all_extents;
+
+ template<typename _Tp>
+ struct __is_array_known_bounds
+ : public integral_constant<bool, (extent<_Tp>::value > 0)>
+ { };
+
+ template<typename _Tp>
+ struct __is_array_unknown_bounds
+ : public __and_<is_array<_Tp>, __not_<extent<_Tp>>>::type
+ { };
+
+ // In N3290 is_destructible does not say anything about function
+ // types and abstract types, see LWG 2049. This implementation
+ // describes function types as non-destructible and all complete
+ // object types as destructible, iff the explicit destructor
+ // call expression is wellformed.
+ struct __do_is_destructible_impl
+ {
+ template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())>
+ static true_type __test(int);
+
+ template<typename>
+ static false_type __test(...);
+ };
+
+ template<typename _Tp>
+ struct __is_destructible_impl
+ : public __do_is_destructible_impl
+ {
+ typedef decltype(__test<_Tp>(0)) type;
+ };
+
+ template<typename _Tp,
+ bool = __or_<is_void<_Tp>,
+ __is_array_unknown_bounds<_Tp>,
+ is_function<_Tp>>::value,
+ bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
+ struct __is_destructible_safe;
+
+ template<typename _Tp>
+ struct __is_destructible_safe<_Tp, false, false>
+ : public __is_destructible_impl<typename
+ remove_all_extents<_Tp>::type>::type
+ { };
+
+ template<typename _Tp>
+ struct __is_destructible_safe<_Tp, true, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_destructible_safe<_Tp, false, true>
+ : public true_type { };
+
+ /// is_destructible
+ template<typename _Tp>
+ struct is_destructible
+ : public __is_destructible_safe<_Tp>::type
+ { };
+
+ // is_nothrow_destructible requires that is_destructible is
+ // satisfied as well. We realize that by mimicing the
+ // implementation of is_destructible but refer to noexcept(expr)
+ // instead of decltype(expr).
+ struct __do_is_nt_destructible_impl
+ {
+ template<typename _Tp>
+ static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())>
+ __test(int);
+
+ template<typename>
+ static false_type __test(...);
+ };
+
+ template<typename _Tp>
+ struct __is_nt_destructible_impl
+ : public __do_is_nt_destructible_impl
+ {
+ typedef decltype(__test<_Tp>(0)) type;
+ };
+
+ template<typename _Tp,
+ bool = __or_<is_void<_Tp>,
+ __is_array_unknown_bounds<_Tp>,
+ is_function<_Tp>>::value,
+ bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value>
+ struct __is_nt_destructible_safe;
+
+ template<typename _Tp>
+ struct __is_nt_destructible_safe<_Tp, false, false>
+ : public __is_nt_destructible_impl<typename
+ remove_all_extents<_Tp>::type>::type
+ { };
+
+ template<typename _Tp>
+ struct __is_nt_destructible_safe<_Tp, true, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_nt_destructible_safe<_Tp, false, true>
+ : public true_type { };
+
+ /// is_nothrow_destructible
+ template<typename _Tp>
+ struct is_nothrow_destructible
+ : public __is_nt_destructible_safe<_Tp>::type
+ { };
+
+ struct __do_is_default_constructible_impl
+ {
+ template<typename _Tp, typename = decltype(_Tp())>
+ static true_type __test(int);
+
+ template<typename>
+ static false_type __test(...);
+ };
+
+ template<typename _Tp>
+ struct __is_default_constructible_impl
+ : public __do_is_default_constructible_impl
+ {
+ typedef decltype(__test<_Tp>(0)) type;
+ };
+
+ template<typename _Tp>
+ struct __is_default_constructible_atom
+ : public __and_<__not_<is_void<_Tp>>,
+ __is_default_constructible_impl<_Tp>>::type
+ { };
+
+ template<typename _Tp, bool = is_array<_Tp>::value>
+ struct __is_default_constructible_safe;
+
+ // The following technique is a workaround for a current core language
+ // restriction, which does not allow for array types to occur in
+ // functional casts of the form T(). Complete arrays can be default-
+ // constructed, if the element type is default-constructible, but
+ // arrays with unknown bounds are not.
+ template<typename _Tp>
+ struct __is_default_constructible_safe<_Tp, true>
+ : public __and_<__is_array_known_bounds<_Tp>,
+ __is_default_constructible_atom<typename
+ remove_all_extents<_Tp>::type>>::type
+ { };
+
+ template<typename _Tp>
+ struct __is_default_constructible_safe<_Tp, false>
+ : public __is_default_constructible_atom<_Tp>::type
+ { };
+
+ /// is_default_constructible
+ template<typename _Tp>
+ struct is_default_constructible
+ : public __is_default_constructible_safe<_Tp>::type
+ { };
+
+
+ // Implementation of is_constructible.
+
+ // The hardest part of this trait is the binary direct-initialization
+ // case, because we hit into a functional cast of the form T(arg).
+ // This implementation uses different strategies depending on the
+ // target type to reduce the test overhead as much as possible:
+ //
+ // a) For a reference target type, we use a static_cast expression
+ // modulo its extra cases.
+ //
+ // b) For a non-reference target type we use a ::new expression.
+ struct __do_is_static_castable_impl
+ {
+ template<typename _From, typename _To, typename
+ = decltype(static_cast<_To>(declval<_From>()))>
+ static true_type __test(int);
+
+ template<typename, typename>
+ static false_type __test(...);
+ };
+
+ template<typename _From, typename _To>
+ struct __is_static_castable_impl
+ : public __do_is_static_castable_impl
+ {
+ typedef decltype(__test<_From, _To>(0)) type;
+ };
+
+ template<typename _From, typename _To>
+ struct __is_static_castable_safe
+ : public __is_static_castable_impl<_From, _To>::type
+ { };
+
+ // __is_static_castable
+ template<typename _From, typename _To>
+ struct __is_static_castable
+ : public integral_constant<bool, (__is_static_castable_safe<
+ _From, _To>::value)>
+ { };
+
+ // Implementation for non-reference types. To meet the proper
+ // variable definition semantics, we also need to test for
+ // is_destructible in this case.
+ // This form should be simplified by a single expression:
+ // ::delete ::new _Tp(declval<_Arg>()), see c++/51222.
+ struct __do_is_direct_constructible_impl
+ {
+ template<typename _Tp, typename _Arg, typename
+ = decltype(::new _Tp(declval<_Arg>()))>
+ static true_type __test(int);
+
+ template<typename, typename>
+ static false_type __test(...);
+ };
+
+ template<typename _Tp, typename _Arg>
+ struct __is_direct_constructible_impl
+ : public __do_is_direct_constructible_impl
+ {
+ typedef decltype(__test<_Tp, _Arg>(0)) type;
+ };
+
+ template<typename _Tp, typename _Arg>
+ struct __is_direct_constructible_new_safe
+ : public __and_<is_destructible<_Tp>,
+ __is_direct_constructible_impl<_Tp, _Arg>>::type
+ { };
+
+ template<typename, typename>
+ struct is_same;
+
+ template<typename, typename>
+ struct is_base_of;
+
+ template<typename>
+ struct remove_reference;
+
+ template<typename _From, typename _To, bool
+ = __not_<__or_<is_void<_From>,
+ is_function<_From>>>::value>
+ struct __is_base_to_derived_ref;
+
+ // Detect whether we have a downcast situation during
+ // reference binding.
+ template<typename _From, typename _To>
+ struct __is_base_to_derived_ref<_From, _To, true>
+ {
+ typedef typename remove_cv<typename remove_reference<_From
+ >::type>::type __src_t;
+ typedef typename remove_cv<typename remove_reference<_To
+ >::type>::type __dst_t;
+ typedef __and_<__not_<is_same<__src_t, __dst_t>>,
+ is_base_of<__src_t, __dst_t>> type;
+ static constexpr bool value = type::value;
+ };
+
+ template<typename _From, typename _To>
+ struct __is_base_to_derived_ref<_From, _To, false>
+ : public false_type
+ { };
+
+ template<typename _From, typename _To, bool
+ = __and_<is_lvalue_reference<_From>,
+ is_rvalue_reference<_To>>::value>
+ struct __is_lvalue_to_rvalue_ref;
+
+ // Detect whether we have an lvalue of non-function type
+ // bound to a reference-compatible rvalue-reference.
+ template<typename _From, typename _To>
+ struct __is_lvalue_to_rvalue_ref<_From, _To, true>
+ {
+ typedef typename remove_cv<typename remove_reference<
+ _From>::type>::type __src_t;
+ typedef typename remove_cv<typename remove_reference<
+ _To>::type>::type __dst_t;
+ typedef __and_<__not_<is_function<__src_t>>,
+ __or_<is_same<__src_t, __dst_t>,
+ is_base_of<__dst_t, __src_t>>> type;
+ static constexpr bool value = type::value;
+ };
+
+ template<typename _From, typename _To>
+ struct __is_lvalue_to_rvalue_ref<_From, _To, false>
+ : public false_type
+ { };
+
+ // Here we handle direct-initialization to a reference type as
+ // equivalent to a static_cast modulo overshooting conversions.
+ // These are restricted to the following conversions:
+ // a) A base class value to a derived class reference
+ // b) An lvalue to an rvalue-reference of reference-compatible
+ // types that are not functions
+ template<typename _Tp, typename _Arg>
+ struct __is_direct_constructible_ref_cast
+ : public __and_<__is_static_castable<_Arg, _Tp>,
+ __not_<__or_<__is_base_to_derived_ref<_Arg, _Tp>,
+ __is_lvalue_to_rvalue_ref<_Arg, _Tp>
+ >>>::type
+ { };
+
+ template<typename _Tp, typename _Arg>
+ struct __is_direct_constructible_new
+ : public conditional<is_reference<_Tp>::value,
+ __is_direct_constructible_ref_cast<_Tp, _Arg>,
+ __is_direct_constructible_new_safe<_Tp, _Arg>
+ >::type
+ { };
+
+ template<typename _Tp, typename _Arg>
+ struct __is_direct_constructible
+ : public __is_direct_constructible_new<_Tp, _Arg>::type
+ { };
+
+ // Since default-construction and binary direct-initialization have
+ // been handled separately, the implementation of the remaining
+ // n-ary construction cases is rather straightforward. We can use
+ // here a functional cast, because array types are excluded anyway
+ // and this form is never interpreted as a C cast.
+ struct __do_is_nary_constructible_impl
+ {
+ template<typename _Tp, typename... _Args, typename
+ = decltype(_Tp(declval<_Args>()...))>
+ static true_type __test(int);
+
+ template<typename, typename...>
+ static false_type __test(...);
+ };
+
+ template<typename _Tp, typename... _Args>
+ struct __is_nary_constructible_impl
+ : public __do_is_nary_constructible_impl
+ {
+ typedef decltype(__test<_Tp, _Args...>(0)) type;
+ };
+
+ template<typename _Tp, typename... _Args>
+ struct __is_nary_constructible
+ : public __is_nary_constructible_impl<_Tp, _Args...>::type
+ {
+ static_assert(sizeof...(_Args) > 1,
+ "Only useful for > 1 arguments");
+ };
+
+ template<typename _Tp, typename... _Args>
+ struct __is_constructible_impl
+ : public __is_nary_constructible<_Tp, _Args...>
+ { };
+
+ template<typename _Tp, typename _Arg>
+ struct __is_constructible_impl<_Tp, _Arg>
+ : public __is_direct_constructible<_Tp, _Arg>
+ { };
+
+ template<typename _Tp>
+ struct __is_constructible_impl<_Tp>
+ : public is_default_constructible<_Tp>
+ { };
+
+ /// is_constructible
+ template<typename _Tp, typename... _Args>
+ struct is_constructible
+ : public __is_constructible_impl<_Tp, _Args...>::type
+ { };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __is_copy_constructible_impl;
+
+ template<typename _Tp>
+ struct __is_copy_constructible_impl<_Tp, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_copy_constructible_impl<_Tp, true>
+ : public is_constructible<_Tp, const _Tp&>
+ { };
+
+ /// is_copy_constructible
+ template<typename _Tp>
+ struct is_copy_constructible
+ : public __is_copy_constructible_impl<_Tp>
+ { };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __is_move_constructible_impl;
+
+ template<typename _Tp>
+ struct __is_move_constructible_impl<_Tp, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_move_constructible_impl<_Tp, true>
+ : public is_constructible<_Tp, _Tp&&>
+ { };
+
+ /// is_move_constructible
+ template<typename _Tp>
+ struct is_move_constructible
+ : public __is_move_constructible_impl<_Tp>
+ { };
+
+ template<typename _Tp>
+ struct __is_nt_default_constructible_atom
+ : public integral_constant<bool, noexcept(_Tp())>
+ { };
+
+ template<typename _Tp, bool = is_array<_Tp>::value>
+ struct __is_nt_default_constructible_impl;
+
+ template<typename _Tp>
+ struct __is_nt_default_constructible_impl<_Tp, true>
+ : public __and_<__is_array_known_bounds<_Tp>,
+ __is_nt_default_constructible_atom<typename
+ remove_all_extents<_Tp>::type>>::type
+ { };
+
+ template<typename _Tp>
+ struct __is_nt_default_constructible_impl<_Tp, false>
+ : public __is_nt_default_constructible_atom<_Tp>
+ { };
+
+ /// is_nothrow_default_constructible
+ template<typename _Tp>
+ struct is_nothrow_default_constructible
+ : public __and_<is_default_constructible<_Tp>,
+ __is_nt_default_constructible_impl<_Tp>>::type
+ { };
+
+ template<typename _Tp, typename... _Args>
+ struct __is_nt_constructible_impl
+ : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))>
+ { };
+
+ template<typename _Tp, typename _Arg>
+ struct __is_nt_constructible_impl<_Tp, _Arg>
+ : public integral_constant<bool,
+ noexcept(static_cast<_Tp>(declval<_Arg>()))>
+ { };
+
+ template<typename _Tp>
+ struct __is_nt_constructible_impl<_Tp>
+ : public is_nothrow_default_constructible<_Tp>
+ { };
+
+ /// is_nothrow_constructible
+ template<typename _Tp, typename... _Args>
+ struct is_nothrow_constructible
+ : public __and_<is_constructible<_Tp, _Args...>,
+ __is_nt_constructible_impl<_Tp, _Args...>>::type
+ { };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __is_nothrow_copy_constructible_impl;
+
+ template<typename _Tp>
+ struct __is_nothrow_copy_constructible_impl<_Tp, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_nothrow_copy_constructible_impl<_Tp, true>
+ : public is_nothrow_constructible<_Tp, const _Tp&>
+ { };
+
+ /// is_nothrow_copy_constructible
+ template<typename _Tp>
+ struct is_nothrow_copy_constructible
+ : public __is_nothrow_copy_constructible_impl<_Tp>
+ { };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __is_nothrow_move_constructible_impl;
+
+ template<typename _Tp>
+ struct __is_nothrow_move_constructible_impl<_Tp, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_nothrow_move_constructible_impl<_Tp, true>
+ : public is_nothrow_constructible<_Tp, _Tp&&>
+ { };
+
+ /// is_nothrow_move_constructible
+ template<typename _Tp>
+ struct is_nothrow_move_constructible
+ : public __is_nothrow_move_constructible_impl<_Tp>
+ { };
+
+ template<typename _Tp, typename _Up>
+ class __is_assignable_helper
+ {
+ template<typename _Tp1, typename _Up1,
+ typename = decltype(declval<_Tp1>() = declval<_Up1>())>
+ static true_type
+ __test(int);
+
+ template<typename, typename>
+ static false_type
+ __test(...);
+
+ public:
+ typedef decltype(__test<_Tp, _Up>(0)) type;
+ };
+
+ /// is_assignable
+ template<typename _Tp, typename _Up>
+ struct is_assignable
+ : public __is_assignable_helper<_Tp, _Up>::type
+ { };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __is_copy_assignable_impl;
+
+ template<typename _Tp>
+ struct __is_copy_assignable_impl<_Tp, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_copy_assignable_impl<_Tp, true>
+ : public is_assignable<_Tp&, const _Tp&>
+ { };
+
+ /// is_copy_assignable
+ template<typename _Tp>
+ struct is_copy_assignable
+ : public __is_copy_assignable_impl<_Tp>
+ { };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __is_move_assignable_impl;
+
+ template<typename _Tp>
+ struct __is_move_assignable_impl<_Tp, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_move_assignable_impl<_Tp, true>
+ : public is_assignable<_Tp&, _Tp&&>
+ { };
+
+ /// is_move_assignable
+ template<typename _Tp>
+ struct is_move_assignable
+ : public __is_move_assignable_impl<_Tp>
+ { };
+
+ template<typename _Tp, typename _Up>
+ struct __is_nt_assignable_impl
+ : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Up>())>
+ { };
+
+ /// is_nothrow_assignable
+ template<typename _Tp, typename _Up>
+ struct is_nothrow_assignable
+ : public __and_<is_assignable<_Tp, _Up>,
+ __is_nt_assignable_impl<_Tp, _Up>>::type
+ { };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __is_nt_copy_assignable_impl;
+
+ template<typename _Tp>
+ struct __is_nt_copy_assignable_impl<_Tp, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_nt_copy_assignable_impl<_Tp, true>
+ : public is_nothrow_assignable<_Tp&, const _Tp&>
+ { };
+
+ /// is_nothrow_copy_assignable
+ template<typename _Tp>
+ struct is_nothrow_copy_assignable
+ : public __is_nt_copy_assignable_impl<_Tp>
+ { };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __is_nt_move_assignable_impl;
+
+ template<typename _Tp>
+ struct __is_nt_move_assignable_impl<_Tp, false>
+ : public false_type { };
+
+ template<typename _Tp>
+ struct __is_nt_move_assignable_impl<_Tp, true>
+ : public is_nothrow_assignable<_Tp&, _Tp&&>
+ { };
+
+ /// is_nothrow_move_assignable
+ template<typename _Tp>
+ struct is_nothrow_move_assignable
+ : public __is_nt_move_assignable_impl<_Tp>
+ { };
+
+ /// is_trivially_constructible (still unimplemented)
+
+ /// is_trivially_default_constructible (still unimplemented)
+
+ /// is_trivially_copy_constructible (still unimplemented)
+
+ /// is_trivially_move_constructible (still unimplemented)
+
+ /// is_trivially_assignable (still unimplemented)
+
+ /// is_trivially_copy_assignable (still unimplemented)
+
+ /// is_trivially_move_assignable (still unimplemented)
+
+ /// is_trivially_destructible
+ template<typename _Tp>
+ struct is_trivially_destructible
+ : public __and_<is_destructible<_Tp>, integral_constant<bool,
+ __has_trivial_destructor(_Tp)>>::type
+ { };
+
+ /// has_trivial_default_constructor (temporary legacy)
+ template<typename _Tp>
+ struct has_trivial_default_constructor
+ : public integral_constant<bool, __has_trivial_constructor(_Tp)>
+ { };
+
+ /// has_trivial_copy_constructor (temporary legacy)
+ template<typename _Tp>
+ struct has_trivial_copy_constructor
+ : public integral_constant<bool, __has_trivial_copy(_Tp)>
+ { };
+
+ /// has_trivial_copy_assign (temporary legacy)
+ template<typename _Tp>
+ struct has_trivial_copy_assign
+ : public integral_constant<bool, __has_trivial_assign(_Tp)>
+ { };
+
+ /// has_virtual_destructor
+ template<typename _Tp>
+ struct has_virtual_destructor
+ : public integral_constant<bool, __has_virtual_destructor(_Tp)>
+ { };
+
+
+ // type property queries.
+
+ /// alignment_of
+ template<typename _Tp>
+ struct alignment_of
+ : public integral_constant<std::size_t, __alignof__(_Tp)> { };
+
+ /// rank
+ template<typename>
+ struct rank
+ : public integral_constant<std::size_t, 0> { };
+
+ template<typename _Tp, std::size_t _Size>
+ struct rank<_Tp[_Size]>
+ : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
+
+ template<typename _Tp>
+ struct rank<_Tp[]>
+ : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
+
+ /// extent
+ template<typename, unsigned _Uint>
+ struct extent
+ : public integral_constant<std::size_t, 0> { };
+
+ template<typename _Tp, unsigned _Uint, std::size_t _Size>
+ struct extent<_Tp[_Size], _Uint>
+ : public integral_constant<std::size_t,
+ _Uint == 0 ? _Size : extent<_Tp,
+ _Uint - 1>::value>
+ { };
+
+ template<typename _Tp, unsigned _Uint>
+ struct extent<_Tp[], _Uint>
+ : public integral_constant<std::size_t,
+ _Uint == 0 ? 0 : extent<_Tp,
+ _Uint - 1>::value>
+ { };
+
+
+ // Type relations.
+
+ /// is_same
+ template<typename, typename>
+ struct is_same
+ : public false_type { };
+
+ template<typename _Tp>
+ struct is_same<_Tp, _Tp>
+ : public true_type { };
+
+ /// is_base_of
+ template<typename _Base, typename _Derived>
+ struct is_base_of
+ : public integral_constant<bool, __is_base_of(_Base, _Derived)>
+ { };
+
+ template<typename _From, typename _To,
+ bool = __or_<is_void<_From>, is_function<_To>,
+ is_array<_To>>::value>
+ struct __is_convertible_helper
+ { typedef typename is_void<_To>::type type; };
+
+ template<typename _From, typename _To>
+ class __is_convertible_helper<_From, _To, false>
+ {
+ template<typename _To1>
+ static void __test_aux(_To1);
+
+ template<typename _From1, typename _To1,
+ typename = decltype(__test_aux<_To1>(std::declval<_From1>()))>
+ static true_type
+ __test(int);
+
+ template<typename, typename>
+ static false_type
+ __test(...);
+
+ public:
+ typedef decltype(__test<_From, _To>(0)) type;
+ };
+
+
+ /// is_convertible
+ template<typename _From, typename _To>
+ struct is_convertible
+ : public __is_convertible_helper<_From, _To>::type
+ { };
+
+
+ // Const-volatile modifications.
+
+ /// remove_const
+ template<typename _Tp>
+ struct remove_const
+ { typedef _Tp type; };
+
+ template<typename _Tp>
+ struct remove_const<_Tp const>
+ { typedef _Tp type; };
+
+ /// remove_volatile
+ template<typename _Tp>
+ struct remove_volatile
+ { typedef _Tp type; };
+
+ template<typename _Tp>
+ struct remove_volatile<_Tp volatile>
+ { typedef _Tp type; };
+
+ /// remove_cv
+ template<typename _Tp>
+ struct remove_cv
+ {
+ typedef typename
+ remove_const<typename remove_volatile<_Tp>::type>::type type;
+ };
+
+ /// add_const
+ template<typename _Tp>
+ struct add_const
+ { typedef _Tp const type; };
+
+ /// add_volatile
+ template<typename _Tp>
+ struct add_volatile
+ { typedef _Tp volatile type; };
+
+ /// add_cv
+ template<typename _Tp>
+ struct add_cv
+ {
+ typedef typename
+ add_const<typename add_volatile<_Tp>::type>::type type;
+ };
+
+#if __cplusplus > 201103L
+ /// Alias template for remove_const
+ template<typename _Tp>
+ using remove_const_t = typename remove_const<_Tp>::type;
+
+ /// Alias template for remove_volatile
+ template<typename _Tp>
+ using remove_volatile_t = typename remove_volatile<_Tp>::type;
+
+ /// Alias template for remove_cv
+ template<typename _Tp>
+ using remove_cv_t = typename remove_cv<_Tp>::type;
+
+ /// Alias template for add_const
+ template<typename _Tp>
+ using add_const_t = typename add_const<_Tp>::type;
+
+ /// Alias template for add_volatile
+ template<typename _Tp>
+ using add_volatile_t = typename add_volatile<_Tp>::type;
+
+ /// Alias template for add_cv
+ template<typename _Tp>
+ using add_cv_t = typename add_cv<_Tp>::type;
+#endif
+
+ // Reference transformations.
+
+ /// remove_reference
+ template<typename _Tp>
+ struct remove_reference
+ { typedef _Tp type; };
+
+ template<typename _Tp>
+ struct remove_reference<_Tp&>
+ { typedef _Tp type; };
+
+ template<typename _Tp>
+ struct remove_reference<_Tp&&>
+ { typedef _Tp type; };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __add_lvalue_reference_helper
+ { typedef _Tp type; };
+
+ template<typename _Tp>
+ struct __add_lvalue_reference_helper<_Tp, true>
+ { typedef _Tp& type; };
+
+ /// add_lvalue_reference
+ template<typename _Tp>
+ struct add_lvalue_reference
+ : public __add_lvalue_reference_helper<_Tp>
+ { };
+
+ template<typename _Tp, bool = __is_referenceable<_Tp>::value>
+ struct __add_rvalue_reference_helper
+ { typedef _Tp type; };
+
+ template<typename _Tp>
+ struct __add_rvalue_reference_helper<_Tp, true>
+ { typedef _Tp&& type; };
+
+ /// add_rvalue_reference
+ template<typename _Tp>
+ struct add_rvalue_reference
+ : public __add_rvalue_reference_helper<_Tp>
+ { };
+
+#if __cplusplus > 201103L
+ /// Alias template for remove_reference
+ template<typename _Tp>
+ using remove_reference_t = typename remove_reference<_Tp>::type;
+
+ /// Alias template for add_lvalue_reference
+ template<typename _Tp>
+ using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
+
+ /// Alias template for add_rvalue_reference
+ template<typename _Tp>
+ using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type;
+#endif
+
+ // Sign modifications.
+
+ // Utility for constructing identically cv-qualified types.
+ template<typename _Unqualified, bool _IsConst, bool _IsVol>
+ struct __cv_selector;
+
+ template<typename _Unqualified>
+ struct __cv_selector<_Unqualified, false, false>
+ { typedef _Unqualified __type; };
+
+ template<typename _Unqualified>
+ struct __cv_selector<_Unqualified, false, true>
+ { typedef volatile _Unqualified __type; };
+
+ template<typename _Unqualified>
+ struct __cv_selector<_Unqualified, true, false>
+ { typedef const _Unqualified __type; };
+
+ template<typename _Unqualified>
+ struct __cv_selector<_Unqualified, true, true>
+ { typedef const volatile _Unqualified __type; };
+
+ template<typename _Qualified, typename _Unqualified,
+ bool _IsConst = is_const<_Qualified>::value,
+ bool _IsVol = is_volatile<_Qualified>::value>
+ class __match_cv_qualifiers
+ {
+ typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match;
+
+ public:
+ typedef typename __match::__type __type;
+ };
+
+ // Utility for finding the unsigned versions of signed integral types.
+ template<typename _Tp>
+ struct __make_unsigned
+ { typedef _Tp __type; };
+
+ template<>
+ struct __make_unsigned<char>
+ { typedef unsigned char __type; };
+
+ template<>
+ struct __make_unsigned<signed char>
+ { typedef unsigned char __type; };
+
+ template<>
+ struct __make_unsigned<short>
+ { typedef unsigned short __type; };
+
+ template<>
+ struct __make_unsigned<int>
+ { typedef unsigned int __type; };
+
+ template<>
+ struct __make_unsigned<long>
+ { typedef unsigned long __type; };
+
+ template<>
+ struct __make_unsigned<long long>
+ { typedef unsigned long long __type; };
+
+#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
+ template<>
+ struct __make_unsigned<__int128>
+ { typedef unsigned __int128 __type; };
+#endif
+
+ // Select between integral and enum: not possible to be both.
+ template<typename _Tp,
+ bool _IsInt = is_integral<_Tp>::value,
+ bool _IsEnum = is_enum<_Tp>::value>
+ class __make_unsigned_selector;
+
+ template<typename _Tp>
+ class __make_unsigned_selector<_Tp, true, false>
+ {
+ typedef __make_unsigned<typename remove_cv<_Tp>::type> __unsignedt;
+ typedef typename __unsignedt::__type __unsigned_type;
+ typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned;
+
+ public:
+ typedef typename __cv_unsigned::__type __type;
+ };
+
+ template<typename _Tp>
+ class __make_unsigned_selector<_Tp, false, true>
+ {
+ // With -fshort-enums, an enum may be as small as a char.
+ typedef unsigned char __smallest;
+ static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
+ static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned short);
+ static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned int);
+ typedef conditional<__b2, unsigned int, unsigned long> __cond2;
+ typedef typename __cond2::type __cond2_type;
+ typedef conditional<__b1, unsigned short, __cond2_type> __cond1;
+ typedef typename __cond1::type __cond1_type;
+
+ public:
+ typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
+ };
+
+ // Given an integral/enum type, return the corresponding unsigned
+ // integer type.
+ // Primary template.
+ /// make_unsigned
+ template<typename _Tp>
+ struct make_unsigned
+ { typedef typename __make_unsigned_selector<_Tp>::__type type; };
+
+ // Integral, but don't define.
+ template<>
+ struct make_unsigned<bool>;
+
+
+ // Utility for finding the signed versions of unsigned integral types.
+ template<typename _Tp>
+ struct __make_signed
+ { typedef _Tp __type; };
+
+ template<>
+ struct __make_signed<char>
+ { typedef signed char __type; };
+
+ template<>
+ struct __make_signed<unsigned char>
+ { typedef signed char __type; };
+
+ template<>
+ struct __make_signed<unsigned short>
+ { typedef signed short __type; };
+
+ template<>
+ struct __make_signed<unsigned int>
+ { typedef signed int __type; };
+
+ template<>
+ struct __make_signed<unsigned long>
+ { typedef signed long __type; };
+
+ template<>
+ struct __make_signed<unsigned long long>
+ { typedef signed long long __type; };
+
+#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
+ template<>
+ struct __make_signed<unsigned __int128>
+ { typedef __int128 __type; };
+#endif
+
+ // Select between integral and enum: not possible to be both.
+ template<typename _Tp,
+ bool _IsInt = is_integral<_Tp>::value,
+ bool _IsEnum = is_enum<_Tp>::value>
+ class __make_signed_selector;
+
+ template<typename _Tp>
+ class __make_signed_selector<_Tp, true, false>
+ {
+ typedef __make_signed<typename remove_cv<_Tp>::type> __signedt;
+ typedef typename __signedt::__type __signed_type;
+ typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed;
+
+ public:
+ typedef typename __cv_signed::__type __type;
+ };
+
+ template<typename _Tp>
+ class __make_signed_selector<_Tp, false, true>
+ {
+ // With -fshort-enums, an enum may be as small as a char.
+ typedef signed char __smallest;
+ static const bool __b0 = sizeof(_Tp) <= sizeof(__smallest);
+ static const bool __b1 = sizeof(_Tp) <= sizeof(signed short);
+ static const bool __b2 = sizeof(_Tp) <= sizeof(signed int);
+ typedef conditional<__b2, signed int, signed long> __cond2;
+ typedef typename __cond2::type __cond2_type;
+ typedef conditional<__b1, signed short, __cond2_type> __cond1;
+ typedef typename __cond1::type __cond1_type;
+
+ public:
+ typedef typename conditional<__b0, __smallest, __cond1_type>::type __type;
+ };
+
+ // Given an integral/enum type, return the corresponding signed
+ // integer type.
+ // Primary template.
+ /// make_signed
+ template<typename _Tp>
+ struct make_signed
+ { typedef typename __make_signed_selector<_Tp>::__type type; };
+
+ // Integral, but don't define.
+ template<>
+ struct make_signed<bool>;
+
+#if __cplusplus > 201103L
+ /// Alias template for make_signed
+ template<typename _Tp>
+ using make_signed_t = typename make_signed<_Tp>::type;
+
+ /// Alias template for make_unsigned
+ template<typename _Tp>
+ using make_unsigned_t = typename make_unsigned<_Tp>::type;
+#endif
+
+ // Array modifications.
+
+ /// remove_extent
+ template<typename _Tp>
+ struct remove_extent
+ { typedef _Tp type; };
+
+ template<typename _Tp, std::size_t _Size>
+ struct remove_extent<_Tp[_Size]>
+ { typedef _Tp type; };
+
+ template<typename _Tp>
+ struct remove_extent<_Tp[]>
+ { typedef _Tp type; };
+
+ /// remove_all_extents
+ template<typename _Tp>
+ struct remove_all_extents
+ { typedef _Tp type; };
+
+ template<typename _Tp, std::size_t _Size>
+ struct remove_all_extents<_Tp[_Size]>
+ { typedef typename remove_all_extents<_Tp>::type type; };
+
+ template<typename _Tp>
+ struct remove_all_extents<_Tp[]>
+ { typedef typename remove_all_extents<_Tp>::type type; };
+
+#if __cplusplus > 201103L
+ /// Alias template for remove_extent
+ template<typename _Tp>
+ using remove_extent_t = typename remove_extent<_Tp>::type;
+
+ /// Alias template for remove_all_extents
+ template<typename _Tp>
+ using remove_all_extents_t = typename remove_all_extents<_Tp>::type;
+#endif
+
+ // Pointer modifications.
+
+ template<typename _Tp, typename>
+ struct __remove_pointer_helper
+ { typedef _Tp type; };
+
+ template<typename _Tp, typename _Up>
+ struct __remove_pointer_helper<_Tp, _Up*>
+ { typedef _Up type; };
+
+ /// remove_pointer
+ template<typename _Tp>
+ struct remove_pointer
+ : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
+ { };
+
+ /// add_pointer
+ template<typename _Tp, bool = __or_<__is_referenceable<_Tp>,
+ is_void<_Tp>>::value>
+ struct __add_pointer_helper
+ { typedef _Tp type; };
+
+ template<typename _Tp>
+ struct __add_pointer_helper<_Tp, true>
+ { typedef typename remove_reference<_Tp>::type* type; };
+
+ template<typename _Tp>
+ struct add_pointer
+ : public __add_pointer_helper<_Tp>
+ { };
+
+#if __cplusplus > 201103L
+ /// Alias template for remove_pointer
+ template<typename _Tp>
+ using remove_pointer_t = typename remove_pointer<_Tp>::type;
+
+ /// Alias template for add_pointer
+ template<typename _Tp>
+ using add_pointer_t = typename add_pointer<_Tp>::type;
+#endif
+
+ template<std::size_t _Len>
+ struct __aligned_storage_msa
+ {
+ union __type
+ {
+ unsigned char __data[_Len];
+ struct __attribute__((__aligned__)) { } __align;
+ };
+ };
+
+ /**
+ * @brief Alignment type.
+ *
+ * The value of _Align is a default-alignment which shall be the
+ * most stringent alignment requirement for any C++ object type
+ * whose size is no greater than _Len (3.9). The member typedef
+ * type shall be a POD type suitable for use as uninitialized
+ * storage for any object whose size is at most _Len and whose
+ * alignment is a divisor of _Align.
+ */
+ template<std::size_t _Len, std::size_t _Align =
+ __alignof__(typename __aligned_storage_msa<_Len>::__type)>
+ struct aligned_storage
+ {
+ union type
+ {
+ unsigned char __data[_Len];
+ struct __attribute__((__aligned__((_Align)))) { } __align;
+ };
+ };
+
+
+ // Decay trait for arrays and functions, used for perfect forwarding
+ // in make_pair, make_tuple, etc.
+ template<typename _Up,
+ bool _IsArray = is_array<_Up>::value,
+ bool _IsFunction = is_function<_Up>::value>
+ struct __decay_selector;
+
+ // NB: DR 705.
+ template<typename _Up>
+ struct __decay_selector<_Up, false, false>
+ { typedef typename remove_cv<_Up>::type __type; };
+
+ template<typename _Up>
+ struct __decay_selector<_Up, true, false>
+ { typedef typename remove_extent<_Up>::type* __type; };
+
+ template<typename _Up>
+ struct __decay_selector<_Up, false, true>
+ { typedef typename add_pointer<_Up>::type __type; };
+
+ /// decay
+ template<typename _Tp>
+ class decay
+ {
+ typedef typename remove_reference<_Tp>::type __remove_type;
+
+ public:
+ typedef typename __decay_selector<__remove_type>::__type type;
+ };
+
+ template<typename _Tp>
+ class reference_wrapper;
+
+ // Helper which adds a reference to a type when given a reference_wrapper
+ template<typename _Tp>
+ struct __strip_reference_wrapper
+ {
+ typedef _Tp __type;
+ };
+
+ template<typename _Tp>
+ struct __strip_reference_wrapper<reference_wrapper<_Tp> >
+ {
+ typedef _Tp& __type;
+ };
+
+ template<typename _Tp>
+ struct __decay_and_strip
+ {
+ typedef typename __strip_reference_wrapper<
+ typename decay<_Tp>::type>::__type __type;
+ };
+
+
+ // Primary template.
+ /// Define a member typedef @c type only if a boolean constant is true.
+ template<bool, typename _Tp = void>
+ struct enable_if
+ { };
+
+ // Partial specialization for true.
+ template<typename _Tp>
+ struct enable_if<true, _Tp>
+ { typedef _Tp type; };
+
+ template<typename... _Cond>
+ using _Require = typename enable_if<__and_<_Cond...>::value>::type;
+
+ // Primary template.
+ /// Define a member typedef @c type to one of two argument types.
+ template<bool _Cond, typename _Iftrue, typename _Iffalse>
+ struct conditional
+ { typedef _Iftrue type; };
+
+ // Partial specialization for false.
+ template<typename _Iftrue, typename _Iffalse>
+ struct conditional<false, _Iftrue, _Iffalse>
+ { typedef _Iffalse type; };
+
+ /// common_type
+ template<typename... _Tp>
+ struct common_type;
+
+ // Sfinae-friendly common_type implementation:
+
+ struct __do_common_type_impl
+ {
+ template<typename _Tp, typename _Up>
+ static __success_type<typename decay<decltype
+ (true ? std::declval<_Tp>()
+ : std::declval<_Up>())>::type> _S_test(int);
+
+ template<typename, typename>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _Tp, typename _Up>
+ struct __common_type_impl
+ : private __do_common_type_impl
+ {
+ typedef decltype(_S_test<_Tp, _Up>(0)) type;
+ };
+
+ struct __do_member_type_wrapper
+ {
+ template<typename _Tp>
+ static __success_type<typename _Tp::type> _S_test(int);
+
+ template<typename>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _Tp>
+ struct __member_type_wrapper
+ : private __do_member_type_wrapper
+ {
+ typedef decltype(_S_test<_Tp>(0)) type;
+ };
+
+ template<typename _CTp, typename... _Args>
+ struct __expanded_common_type_wrapper
+ {
+ typedef common_type<typename _CTp::type, _Args...> type;
+ };
+
+ template<typename... _Args>
+ struct __expanded_common_type_wrapper<__failure_type, _Args...>
+ { typedef __failure_type type; };
+
+ template<typename _Tp>
+ struct common_type<_Tp>
+ { typedef typename decay<_Tp>::type type; };
+
+ template<typename _Tp, typename _Up>
+ struct common_type<_Tp, _Up>
+ : public __common_type_impl<_Tp, _Up>::type
+ { };
+
+ template<typename _Tp, typename _Up, typename... _Vp>
+ struct common_type<_Tp, _Up, _Vp...>
+ : public __expanded_common_type_wrapper<typename __member_type_wrapper<
+ common_type<_Tp, _Up>>::type, _Vp...>::type
+ { };
+
+ /// The underlying type of an enum.
+ template<typename _Tp>
+ struct underlying_type
+ {
+ typedef __underlying_type(_Tp) type;
+ };
+
+ template<typename _Tp>
+ struct __declval_protector
+ {
+ static const bool __stop = false;
+ static typename add_rvalue_reference<_Tp>::type __delegate();
+ };
+
+ template<typename _Tp>
+ inline typename add_rvalue_reference<_Tp>::type
+ declval() noexcept
+ {
+ static_assert(__declval_protector<_Tp>::__stop,
+ "declval() must not be used!");
+ return __declval_protector<_Tp>::__delegate();
+ }
+
+ /// result_of
+ template<typename _Signature>
+ class result_of;
+
+ // Sfinae-friendly result_of implementation:
+
+ // [func.require] paragraph 1 bullet 1:
+ struct __result_of_memfun_ref_impl
+ {
+ template<typename _Fp, typename _Tp1, typename... _Args>
+ static __success_type<decltype(
+ (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...)
+ )> _S_test(int);
+
+ template<typename...>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _MemPtr, typename _Arg, typename... _Args>
+ struct __result_of_memfun_ref
+ : private __result_of_memfun_ref_impl
+ {
+ typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
+ };
+
+ // [func.require] paragraph 1 bullet 2:
+ struct __result_of_memfun_deref_impl
+ {
+ template<typename _Fp, typename _Tp1, typename... _Args>
+ static __success_type<decltype(
+ ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...)
+ )> _S_test(int);
+
+ template<typename...>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _MemPtr, typename _Arg, typename... _Args>
+ struct __result_of_memfun_deref
+ : private __result_of_memfun_deref_impl
+ {
+ typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type;
+ };
+
+ // [func.require] paragraph 1 bullet 3:
+ struct __result_of_memobj_ref_impl
+ {
+ template<typename _Fp, typename _Tp1>
+ static __success_type<decltype(
+ std::declval<_Tp1>().*std::declval<_Fp>()
+ )> _S_test(int);
+
+ template<typename, typename>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _MemPtr, typename _Arg>
+ struct __result_of_memobj_ref
+ : private __result_of_memobj_ref_impl
+ {
+ typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
+ };
+
+ // [func.require] paragraph 1 bullet 4:
+ struct __result_of_memobj_deref_impl
+ {
+ template<typename _Fp, typename _Tp1>
+ static __success_type<decltype(
+ (*std::declval<_Tp1>()).*std::declval<_Fp>()
+ )> _S_test(int);
+
+ template<typename, typename>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _MemPtr, typename _Arg>
+ struct __result_of_memobj_deref
+ : private __result_of_memobj_deref_impl
+ {
+ typedef decltype(_S_test<_MemPtr, _Arg>(0)) type;
+ };
+
+ template<typename _MemPtr, typename _Arg>
+ struct __result_of_memobj;
+
+ template<typename _Res, typename _Class, typename _Arg>
+ struct __result_of_memobj<_Res _Class::*, _Arg>
+ {
+ typedef typename remove_cv<typename remove_reference<
+ _Arg>::type>::type _Argval;
+ typedef _Res _Class::* _MemPtr;
+ typedef typename conditional<__or_<is_same<_Argval, _Class>,
+ is_base_of<_Class, _Argval>>::value,
+ __result_of_memobj_ref<_MemPtr, _Arg>,
+ __result_of_memobj_deref<_MemPtr, _Arg>
+ >::type::type type;
+ };
+
+ template<typename _MemPtr, typename _Arg, typename... _Args>
+ struct __result_of_memfun;
+
+ template<typename _Res, typename _Class, typename _Arg, typename... _Args>
+ struct __result_of_memfun<_Res _Class::*, _Arg, _Args...>
+ {
+ typedef typename remove_cv<typename remove_reference<
+ _Arg>::type>::type _Argval;
+ typedef _Res _Class::* _MemPtr;
+ typedef typename conditional<__or_<is_same<_Argval, _Class>,
+ is_base_of<_Class, _Argval>>::value,
+ __result_of_memfun_ref<_MemPtr, _Arg, _Args...>,
+ __result_of_memfun_deref<_MemPtr, _Arg, _Args...>
+ >::type::type type;
+ };
+
+ template<bool, bool, typename _Functor, typename... _ArgTypes>
+ struct __result_of_impl
+ {
+ typedef __failure_type type;
+ };
+
+ template<typename _MemPtr, typename _Arg>
+ struct __result_of_impl<true, false, _MemPtr, _Arg>
+ : public __result_of_memobj<typename decay<_MemPtr>::type, _Arg>
+ { };
+
+ template<typename _MemPtr, typename _Arg, typename... _Args>
+ struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...>
+ : public __result_of_memfun<typename decay<_MemPtr>::type, _Arg, _Args...>
+ { };
+
+ // [func.require] paragraph 1 bullet 5:
+ struct __result_of_other_impl
+ {
+ template<typename _Fn, typename... _Args>
+ static __success_type<decltype(
+ std::declval<_Fn>()(std::declval<_Args>()...)
+ )> _S_test(int);
+
+ template<typename...>
+ static __failure_type _S_test(...);
+ };
+
+ template<typename _Functor, typename... _ArgTypes>
+ struct __result_of_impl<false, false, _Functor, _ArgTypes...>
+ : private __result_of_other_impl
+ {
+ typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type;
+ };
+
+ template<typename _Functor, typename... _ArgTypes>
+ struct result_of<_Functor(_ArgTypes...)>
+ : public __result_of_impl<
+ is_member_object_pointer<
+ typename remove_reference<_Functor>::type
+ >::value,
+ is_member_function_pointer<
+ typename remove_reference<_Functor>::type
+ >::value,
+ _Functor, _ArgTypes...
+ >::type
+ { };
+
+#if __cplusplus > 201103L
+ /// Alias template for aligned_storage
+ template<size_t _Len, size_t _Align =
+ __alignof__(typename __aligned_storage_msa<_Len>::__type)>
+ using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
+
+ /// Alias template for decay
+ template<typename _Tp>
+ using decay_t = typename decay<_Tp>::type;
+
+ /// Alias template for enable_if
+ template<bool _Cond, typename _Tp = void>
+ using enable_if_t = typename enable_if<_Cond, _Tp>::type;
+
+ /// Alias template for conditional
+ template<bool _Cond, typename _Iftrue, typename _Iffalse>
+ using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
+
+ /// Alias template for common_type
+ template<typename... _Tp>
+ using common_type_t = typename common_type<_Tp...>::type;
+
+ /// Alias template for underlying_type
+ template<typename _Tp>
+ using underlying_type_t = typename underlying_type<_Tp>::type;
+
+ /// Alias template for result_of
+ template<typename _Tp>
+ using result_of_t = typename result_of<_Tp>::type;
+#endif
+
+ /// @} group metaprogramming
+
+ /**
+ * Use SFINAE to determine if the type _Tp has a publicly-accessible
+ * member type _NTYPE.
+ */
+#define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \
+ template<typename _Tp> \
+ class __has_##_NTYPE##_helper \
+ { \
+ template<typename _Up> \
+ struct _Wrap_type \
+ { }; \
+ \
+ template<typename _Up> \
+ static true_type __test(_Wrap_type<typename _Up::_NTYPE>*); \
+ \
+ template<typename _Up> \
+ static false_type __test(...); \
+ \
+ public: \
+ typedef decltype(__test<_Tp>(0)) type; \
+ }; \
+ \
+ template<typename _Tp> \
+ struct __has_##_NTYPE \
+ : public __has_##_NTYPE##_helper \
+ <typename remove_cv<_Tp>::type>::type \
+ { };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+
+#endif // C++11
+
+#endif // _GLIBCXX_TYPE_TRAITS
diff --git a/gcc-4.9/libstdc++-v3/include/std/typeindex b/gcc-4.9/libstdc++-v3/include/std/typeindex
new file mode 100644
index 0000000..c158feb
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/typeindex
@@ -0,0 +1,112 @@
+// C++11 <typeindex> -*- C++ -*-
+
+// Copyright (C) 2010-2014 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/typeindex
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_TYPEINDEX
+#define _GLIBCXX_TYPEINDEX 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <typeinfo>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @brief Class type_index
+ * @ingroup utilities
+ *
+ * The class type_index provides a simple wrapper for type_info
+ * which can be used as an index type in associative containers
+ * (23.6) and in unordered associative containers (23.7).
+ */
+ struct type_index
+ {
+ type_index(const type_info& __rhs) noexcept
+ : _M_target(&__rhs) { }
+
+ bool
+ operator==(const type_index& __rhs) const noexcept
+ { return *_M_target == *__rhs._M_target; }
+
+ bool
+ operator!=(const type_index& __rhs) const noexcept
+ { return *_M_target != *__rhs._M_target; }
+
+ bool
+ operator<(const type_index& __rhs) const noexcept
+ { return _M_target->before(*__rhs._M_target); }
+
+ bool
+ operator<=(const type_index& __rhs) const noexcept
+ { return !__rhs._M_target->before(*_M_target); }
+
+ bool
+ operator>(const type_index& __rhs) const noexcept
+ { return __rhs._M_target->before(*_M_target); }
+
+ bool
+ operator>=(const type_index& __rhs) const noexcept
+ { return !_M_target->before(*__rhs._M_target); }
+
+ size_t
+ hash_code() const noexcept
+ { return _M_target->hash_code(); }
+
+ const char*
+ name() const noexcept
+ { return _M_target->name(); }
+
+ private:
+ const type_info* _M_target;
+ };
+
+ template<typename _Tp> struct hash;
+
+ /// std::hash specialization for type_index.
+ template<>
+ struct hash<type_index>
+ {
+ typedef size_t result_type;
+ typedef type_index argument_type;
+
+ size_t
+ operator()(const type_index& __ti) const noexcept
+ { return __ti.hash_code(); }
+ };
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+
+#endif // C++11
+
+#endif // _GLIBCXX_TYPEINDEX
diff --git a/gcc-4.9/libstdc++-v3/include/std/unordered_map b/gcc-4.9/libstdc++-v3/include/std/unordered_map
new file mode 100644
index 0000000..32da303
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/unordered_map
@@ -0,0 +1,61 @@
+// <unordered_map> -*- C++ -*-
+
+// Copyright (C) 2007-2014 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/unordered_map
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_UNORDERED_MAP
+#define _GLIBCXX_UNORDERED_MAP 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <utility>
+#include <type_traits>
+#include <initializer_list>
+#include <tuple>
+#include <bits/allocator.h>
+#include <ext/alloc_traits.h>
+#include <ext/aligned_buffer.h>
+#include <bits/stl_function.h> // equal_to, _Identity, _Select1st
+#include <bits/functional_hash.h>
+#include <bits/hashtable.h>
+#include <bits/unordered_map.h>
+#include <bits/range_access.h>
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/unordered_map>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/unordered_map>
+#endif
+
+#endif // C++11
+
+#endif // _GLIBCXX_UNORDERED_MAP
diff --git a/gcc-4.9/libstdc++-v3/include/std/unordered_set b/gcc-4.9/libstdc++-v3/include/std/unordered_set
new file mode 100644
index 0000000..da55f2c
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/unordered_set
@@ -0,0 +1,60 @@
+// <unordered_set> -*- C++ -*-
+
+// Copyright (C) 2007-2014 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/unordered_set
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_UNORDERED_SET
+#define _GLIBCXX_UNORDERED_SET 1
+
+#pragma GCC system_header
+
+#if __cplusplus < 201103L
+# include <bits/c++0x_warning.h>
+#else
+
+#include <utility>
+#include <type_traits>
+#include <initializer_list>
+#include <tuple>
+#include <bits/allocator.h>
+#include <ext/alloc_traits.h>
+#include <ext/aligned_buffer.h>
+#include <bits/stl_function.h> // equal_to, _Identity, _Select1st
+#include <bits/functional_hash.h>
+#include <bits/hashtable.h>
+#include <bits/unordered_set.h>
+#include <bits/range_access.h>
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/unordered_set>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/unordered_set>
+#endif
+#endif // C++11
+
+#endif // _GLIBCXX_UNORDERED_SET
diff --git a/gcc-4.9/libstdc++-v3/include/std/utility b/gcc-4.9/libstdc++-v3/include/std/utility
new file mode 100644
index 0000000..4da9209
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/utility
@@ -0,0 +1,263 @@
+// <utility> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/utility
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_UTILITY
+#define _GLIBCXX_UTILITY 1
+
+#pragma GCC system_header
+
+/**
+ * @defgroup utilities Utilities
+ *
+ * Components deemed generally useful. Includes pair, tuple,
+ * forward/move helpers, ratio, function object, metaprogramming and
+ * type traits, time, date, and memory functions.
+ */
+
+#include <bits/c++config.h>
+#include <bits/stl_relops.h>
+#include <bits/stl_pair.h>
+
+#if __cplusplus >= 201103L
+#include <bits/move.h>
+#include <initializer_list>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<class _Tp>
+ class tuple_size;
+
+ template<std::size_t _Int, class _Tp>
+ class tuple_element;
+
+ // Various functions which give std::pair a tuple-like interface.
+ template<class _Tp1, class _Tp2>
+ struct tuple_size<std::pair<_Tp1, _Tp2>>
+ : public integral_constant<std::size_t, 2> { };
+
+ template<class _Tp1, class _Tp2>
+ struct tuple_element<0, std::pair<_Tp1, _Tp2>>
+ { typedef _Tp1 type; };
+
+ template<class _Tp1, class _Tp2>
+ struct tuple_element<1, std::pair<_Tp1, _Tp2>>
+ { typedef _Tp2 type; };
+
+ template<std::size_t _Int>
+ struct __pair_get;
+
+ template<>
+ struct __pair_get<0>
+ {
+ template<typename _Tp1, typename _Tp2>
+ static constexpr _Tp1&
+ __get(std::pair<_Tp1, _Tp2>& __pair) noexcept
+ { return __pair.first; }
+
+ template<typename _Tp1, typename _Tp2>
+ static constexpr _Tp1&&
+ __move_get(std::pair<_Tp1, _Tp2>&& __pair) noexcept
+ { return std::forward<_Tp1>(__pair.first); }
+
+ template<typename _Tp1, typename _Tp2>
+ static constexpr const _Tp1&
+ __const_get(const std::pair<_Tp1, _Tp2>& __pair) noexcept
+ { return __pair.first; }
+ };
+
+ template<>
+ struct __pair_get<1>
+ {
+ template<typename _Tp1, typename _Tp2>
+ static constexpr _Tp2&
+ __get(std::pair<_Tp1, _Tp2>& __pair) noexcept
+ { return __pair.second; }
+
+ template<typename _Tp1, typename _Tp2>
+ static constexpr _Tp2&&
+ __move_get(std::pair<_Tp1, _Tp2>&& __pair) noexcept
+ { return std::forward<_Tp2>(__pair.second); }
+
+ template<typename _Tp1, typename _Tp2>
+ static constexpr const _Tp2&
+ __const_get(const std::pair<_Tp1, _Tp2>& __pair) noexcept
+ { return __pair.second; }
+ };
+
+ template<std::size_t _Int, class _Tp1, class _Tp2>
+ constexpr typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&
+ get(std::pair<_Tp1, _Tp2>& __in) noexcept
+ { return __pair_get<_Int>::__get(__in); }
+
+ template<std::size_t _Int, class _Tp1, class _Tp2>
+ constexpr typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&&
+ get(std::pair<_Tp1, _Tp2>&& __in) noexcept
+ { return __pair_get<_Int>::__move_get(std::move(__in)); }
+
+ template<std::size_t _Int, class _Tp1, class _Tp2>
+ constexpr const typename tuple_element<_Int, std::pair<_Tp1, _Tp2>>::type&
+ get(const std::pair<_Tp1, _Tp2>& __in) noexcept
+ { return __pair_get<_Int>::__const_get(__in); }
+
+#if __cplusplus > 201103L
+ template <typename _Tp, typename _Up>
+ constexpr _Tp&
+ get(pair<_Tp, _Up>& __p) noexcept
+ { return __p.first; }
+
+ template <typename _Tp, typename _Up>
+ constexpr const _Tp&
+ get(const pair<_Tp, _Up>& __p) noexcept
+ { return __p.first; }
+
+ template <typename _Tp, typename _Up>
+ constexpr _Tp&&
+ get(pair<_Tp, _Up>&& __p) noexcept
+ { return std::move(__p.first); }
+
+ template <typename _Tp, typename _Up>
+ constexpr _Tp&
+ get(pair<_Up, _Tp>& __p) noexcept
+ { return __p.second; }
+
+ template <typename _Tp, typename _Up>
+ constexpr const _Tp&
+ get(const pair<_Up, _Tp>& __p) noexcept
+ { return __p.second; }
+
+ template <typename _Tp, typename _Up>
+ constexpr _Tp&&
+ get(pair<_Up, _Tp>&& __p) noexcept
+ { return std::move(__p.second); }
+
+ /// Assign @p __new_val to @p __obj and return its previous value.
+ template <typename _Tp, typename _Up = _Tp>
+ inline _Tp
+ exchange(_Tp& __obj, _Up&& __new_val)
+ {
+ _Tp __old_val = std::move(__obj);
+ __obj = std::forward<_Up>(__new_val);
+ return __old_val;
+ }
+#endif
+
+ // Stores a tuple of indices. Used by tuple and pair, and by bind() to
+ // extract the elements in a tuple.
+ template<size_t... _Indexes>
+ struct _Index_tuple
+ {
+ typedef _Index_tuple<_Indexes..., sizeof...(_Indexes)> __next;
+ };
+
+ // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>.
+ template<size_t _Num>
+ struct _Build_index_tuple
+ {
+ typedef typename _Build_index_tuple<_Num - 1>::__type::__next __type;
+ };
+
+ template<>
+ struct _Build_index_tuple<0>
+ {
+ typedef _Index_tuple<> __type;
+ };
+
+#if __cplusplus > 201103L
+ /// Class template integer_sequence
+ template<typename _Tp, _Tp... _Idx>
+ struct integer_sequence
+ {
+ typedef _Tp value_type;
+ static constexpr size_t size() { return sizeof...(_Idx); }
+ };
+
+ template<typename _Tp, _Tp _Num,
+ typename _ISeq = typename _Build_index_tuple<_Num>::__type>
+ struct _Make_integer_sequence;
+
+ template<typename _Tp, _Tp _Num, size_t... _Idx>
+ struct _Make_integer_sequence<_Tp, _Num, _Index_tuple<_Idx...>>
+ {
+ static_assert( _Num >= 0,
+ "Cannot make integer sequence of negative length" );
+
+ typedef integer_sequence<_Tp, static_cast<_Tp>(_Idx)...> __type;
+ };
+
+ /// Alias template make_integer_sequence
+ template<typename _Tp, _Tp _Num>
+ using make_integer_sequence
+ = typename _Make_integer_sequence<_Tp, _Num>::__type;
+
+ /// Alias template index_sequence
+ template<size_t... _Idx>
+ using index_sequence = integer_sequence<size_t, _Idx...>;
+
+ /// Alias template make_index_sequence
+ template<size_t _Num>
+ using make_index_sequence = make_integer_sequence<size_t, _Num>;
+
+ /// Alias template index_sequence_for
+ template<typename... _Types>
+ using index_sequence_for = make_index_sequence<sizeof...(_Types)>;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif
+
+#endif /* _GLIBCXX_UTILITY */
diff --git a/gcc-4.9/libstdc++-v3/include/std/valarray b/gcc-4.9/libstdc++-v3/include/std/valarray
new file mode 100644
index 0000000..e0d48dc
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/valarray
@@ -0,0 +1,1235 @@
+// The template and inlines for the -*- C++ -*- valarray class.
+
+// Copyright (C) 1997-2014 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/valarray
+ * This is a Standard C++ Library header.
+ */
+
+// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr>
+
+#ifndef _GLIBCXX_VALARRAY
+#define _GLIBCXX_VALARRAY 1
+
+#pragma GCC system_header
+
+#include <bits/c++config.h>
+#include <cmath>
+#include <algorithm>
+#include <debug/debug.h>
+#if __cplusplus >= 201103L
+#include <initializer_list>
+#endif
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template<class _Clos, typename _Tp>
+ class _Expr;
+
+ template<typename _Tp1, typename _Tp2>
+ class _ValArray;
+
+ template<class _Oper, template<class, class> class _Meta, class _Dom>
+ struct _UnClos;
+
+ template<class _Oper,
+ template<class, class> class _Meta1,
+ template<class, class> class _Meta2,
+ class _Dom1, class _Dom2>
+ class _BinClos;
+
+ template<template<class, class> class _Meta, class _Dom>
+ class _SClos;
+
+ template<template<class, class> class _Meta, class _Dom>
+ class _GClos;
+
+ template<template<class, class> class _Meta, class _Dom>
+ class _IClos;
+
+ template<template<class, class> class _Meta, class _Dom>
+ class _ValFunClos;
+
+ template<template<class, class> class _Meta, class _Dom>
+ class _RefFunClos;
+
+ template<class _Tp> class valarray; // An array of type _Tp
+ class slice; // BLAS-like slice out of an array
+ template<class _Tp> class slice_array;
+ class gslice; // generalized slice out of an array
+ template<class _Tp> class gslice_array;
+ template<class _Tp> class mask_array; // masked array
+ template<class _Tp> class indirect_array; // indirected array
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#include <bits/valarray_array.h>
+#include <bits/valarray_before.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @defgroup numeric_arrays Numeric Arrays
+ * @ingroup numerics
+ *
+ * Classes and functions for representing and manipulating arrays of elements.
+ * @{
+ */
+
+ /**
+ * @brief Smart array designed to support numeric processing.
+ *
+ * A valarray is an array that provides constraints intended to allow for
+ * effective optimization of numeric array processing by reducing the
+ * aliasing that can result from pointer representations. It represents a
+ * one-dimensional array from which different multidimensional subsets can
+ * be accessed and modified.
+ *
+ * @tparam _Tp Type of object in the array.
+ */
+ template<class _Tp>
+ class valarray
+ {
+ template<class _Op>
+ struct _UnaryOp
+ {
+ typedef typename __fun<_Op, _Tp>::result_type __rt;
+ typedef _Expr<_UnClos<_Op, _ValArray, _Tp>, __rt> _Rt;
+ };
+ public:
+ typedef _Tp value_type;
+
+ // _lib.valarray.cons_ construct/destroy:
+ /// Construct an empty array.
+ valarray();
+
+ /// Construct an array with @a n elements.
+ explicit valarray(size_t);
+
+ /// Construct an array with @a n elements initialized to @a t.
+ valarray(const _Tp&, size_t);
+
+ /// Construct an array initialized to the first @a n elements of @a t.
+ valarray(const _Tp* __restrict__, size_t);
+
+ /// Copy constructor.
+ valarray(const valarray&);
+
+#if __cplusplus >= 201103L
+ /// Move constructor.
+ valarray(valarray&&) noexcept;
+#endif
+
+ /// Construct an array with the same size and values in @a sa.
+ valarray(const slice_array<_Tp>&);
+
+ /// Construct an array with the same size and values in @a ga.
+ valarray(const gslice_array<_Tp>&);
+
+ /// Construct an array with the same size and values in @a ma.
+ valarray(const mask_array<_Tp>&);
+
+ /// Construct an array with the same size and values in @a ia.
+ valarray(const indirect_array<_Tp>&);
+
+#if __cplusplus >= 201103L
+ /// Construct an array with an initializer_list of values.
+ valarray(initializer_list<_Tp>);
+#endif
+
+ template<class _Dom>
+ valarray(const _Expr<_Dom, _Tp>& __e);
+
+ ~valarray() _GLIBCXX_NOEXCEPT;
+
+ // _lib.valarray.assign_ assignment:
+ /**
+ * @brief Assign elements to an array.
+ *
+ * Assign elements of array to values in @a v.
+ *
+ * @param __v Valarray to get values from.
+ */
+ valarray<_Tp>& operator=(const valarray<_Tp>& __v);
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Move assign elements to an array.
+ *
+ * Move assign elements of array to values in @a v.
+ *
+ * @param __v Valarray to get values from.
+ */
+ valarray<_Tp>& operator=(valarray<_Tp>&& __v) noexcept;
+#endif
+
+ /**
+ * @brief Assign elements to a value.
+ *
+ * Assign all elements of array to @a t.
+ *
+ * @param __t Value for elements.
+ */
+ valarray<_Tp>& operator=(const _Tp& __t);
+
+ /**
+ * @brief Assign elements to an array subset.
+ *
+ * Assign elements of array to values in @a sa. Results are undefined
+ * if @a sa does not have the same size as this array.
+ *
+ * @param __sa Array slice to get values from.
+ */
+ valarray<_Tp>& operator=(const slice_array<_Tp>& __sa);
+
+ /**
+ * @brief Assign elements to an array subset.
+ *
+ * Assign elements of array to values in @a ga. Results are undefined
+ * if @a ga does not have the same size as this array.
+ *
+ * @param __ga Array slice to get values from.
+ */
+ valarray<_Tp>& operator=(const gslice_array<_Tp>& __ga);
+
+ /**
+ * @brief Assign elements to an array subset.
+ *
+ * Assign elements of array to values in @a ma. Results are undefined
+ * if @a ma does not have the same size as this array.
+ *
+ * @param __ma Array slice to get values from.
+ */
+ valarray<_Tp>& operator=(const mask_array<_Tp>& __ma);
+
+ /**
+ * @brief Assign elements to an array subset.
+ *
+ * Assign elements of array to values in @a ia. Results are undefined
+ * if @a ia does not have the same size as this array.
+ *
+ * @param __ia Array slice to get values from.
+ */
+ valarray<_Tp>& operator=(const indirect_array<_Tp>& __ia);
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Assign elements to an initializer_list.
+ *
+ * Assign elements of array to values in @a __l. Results are undefined
+ * if @a __l does not have the same size as this array.
+ *
+ * @param __l initializer_list to get values from.
+ */
+ valarray& operator=(initializer_list<_Tp> __l);
+#endif
+
+ template<class _Dom> valarray<_Tp>&
+ operator= (const _Expr<_Dom, _Tp>&);
+
+ // _lib.valarray.access_ element access:
+ /**
+ * Return a reference to the i'th array element.
+ *
+ * @param __i Index of element to return.
+ * @return Reference to the i'th element.
+ */
+ _Tp& operator[](size_t __i);
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 389. Const overload of valarray::operator[] returns by value.
+ const _Tp& operator[](size_t) const;
+
+ // _lib.valarray.sub_ subset operations:
+ /**
+ * @brief Return an array subset.
+ *
+ * Returns a new valarray containing the elements of the array
+ * indicated by the slice argument. The new valarray has the same size
+ * as the input slice. @see slice.
+ *
+ * @param __s The source slice.
+ * @return New valarray containing elements in @a __s.
+ */
+ _Expr<_SClos<_ValArray, _Tp>, _Tp> operator[](slice __s) const;
+
+ /**
+ * @brief Return a reference to an array subset.
+ *
+ * Returns a new valarray containing the elements of the array
+ * indicated by the slice argument. The new valarray has the same size
+ * as the input slice. @see slice.
+ *
+ * @param __s The source slice.
+ * @return New valarray containing elements in @a __s.
+ */
+ slice_array<_Tp> operator[](slice __s);
+
+ /**
+ * @brief Return an array subset.
+ *
+ * Returns a slice_array referencing the elements of the array
+ * indicated by the slice argument. @see gslice.
+ *
+ * @param __s The source slice.
+ * @return Slice_array referencing elements indicated by @a __s.
+ */
+ _Expr<_GClos<_ValArray, _Tp>, _Tp> operator[](const gslice& __s) const;
+
+ /**
+ * @brief Return a reference to an array subset.
+ *
+ * Returns a new valarray containing the elements of the array
+ * indicated by the gslice argument. The new valarray has
+ * the same size as the input gslice. @see gslice.
+ *
+ * @param __s The source gslice.
+ * @return New valarray containing elements in @a __s.
+ */
+ gslice_array<_Tp> operator[](const gslice& __s);
+
+ /**
+ * @brief Return an array subset.
+ *
+ * Returns a new valarray containing the elements of the array
+ * indicated by the argument. The input is a valarray of bool which
+ * represents a bitmask indicating which elements should be copied into
+ * the new valarray. Each element of the array is added to the return
+ * valarray if the corresponding element of the argument is true.
+ *
+ * @param __m The valarray bitmask.
+ * @return New valarray containing elements indicated by @a __m.
+ */
+ valarray<_Tp> operator[](const valarray<bool>& __m) const;
+
+ /**
+ * @brief Return a reference to an array subset.
+ *
+ * Returns a new mask_array referencing the elements of the array
+ * indicated by the argument. The input is a valarray of bool which
+ * represents a bitmask indicating which elements are part of the
+ * subset. Elements of the array are part of the subset if the
+ * corresponding element of the argument is true.
+ *
+ * @param __m The valarray bitmask.
+ * @return New valarray containing elements indicated by @a __m.
+ */
+ mask_array<_Tp> operator[](const valarray<bool>& __m);
+
+ /**
+ * @brief Return an array subset.
+ *
+ * Returns a new valarray containing the elements of the array
+ * indicated by the argument. The elements in the argument are
+ * interpreted as the indices of elements of this valarray to copy to
+ * the return valarray.
+ *
+ * @param __i The valarray element index list.
+ * @return New valarray containing elements in @a __s.
+ */
+ _Expr<_IClos<_ValArray, _Tp>, _Tp>
+ operator[](const valarray<size_t>& __i) const;
+
+ /**
+ * @brief Return a reference to an array subset.
+ *
+ * Returns an indirect_array referencing the elements of the array
+ * indicated by the argument. The elements in the argument are
+ * interpreted as the indices of elements of this valarray to include
+ * in the subset. The returned indirect_array refers to these
+ * elements.
+ *
+ * @param __i The valarray element index list.
+ * @return Indirect_array referencing elements in @a __i.
+ */
+ indirect_array<_Tp> operator[](const valarray<size_t>& __i);
+
+ // _lib.valarray.unary_ unary operators:
+ /// Return a new valarray by applying unary + to each element.
+ typename _UnaryOp<__unary_plus>::_Rt operator+() const;
+
+ /// Return a new valarray by applying unary - to each element.
+ typename _UnaryOp<__negate>::_Rt operator-() const;
+
+ /// Return a new valarray by applying unary ~ to each element.
+ typename _UnaryOp<__bitwise_not>::_Rt operator~() const;
+
+ /// Return a new valarray by applying unary ! to each element.
+ typename _UnaryOp<__logical_not>::_Rt operator!() const;
+
+ // _lib.valarray.cassign_ computed assignment:
+ /// Multiply each element of array by @a t.
+ valarray<_Tp>& operator*=(const _Tp&);
+
+ /// Divide each element of array by @a t.
+ valarray<_Tp>& operator/=(const _Tp&);
+
+ /// Set each element e of array to e % @a t.
+ valarray<_Tp>& operator%=(const _Tp&);
+
+ /// Add @a t to each element of array.
+ valarray<_Tp>& operator+=(const _Tp&);
+
+ /// Subtract @a t to each element of array.
+ valarray<_Tp>& operator-=(const _Tp&);
+
+ /// Set each element e of array to e ^ @a t.
+ valarray<_Tp>& operator^=(const _Tp&);
+
+ /// Set each element e of array to e & @a t.
+ valarray<_Tp>& operator&=(const _Tp&);
+
+ /// Set each element e of array to e | @a t.
+ valarray<_Tp>& operator|=(const _Tp&);
+
+ /// Left shift each element e of array by @a t bits.
+ valarray<_Tp>& operator<<=(const _Tp&);
+
+ /// Right shift each element e of array by @a t bits.
+ valarray<_Tp>& operator>>=(const _Tp&);
+
+ /// Multiply elements of array by corresponding elements of @a v.
+ valarray<_Tp>& operator*=(const valarray<_Tp>&);
+
+ /// Divide elements of array by corresponding elements of @a v.
+ valarray<_Tp>& operator/=(const valarray<_Tp>&);
+
+ /// Modulo elements of array by corresponding elements of @a v.
+ valarray<_Tp>& operator%=(const valarray<_Tp>&);
+
+ /// Add corresponding elements of @a v to elements of array.
+ valarray<_Tp>& operator+=(const valarray<_Tp>&);
+
+ /// Subtract corresponding elements of @a v from elements of array.
+ valarray<_Tp>& operator-=(const valarray<_Tp>&);
+
+ /// Logical xor corresponding elements of @a v with elements of array.
+ valarray<_Tp>& operator^=(const valarray<_Tp>&);
+
+ /// Logical or corresponding elements of @a v with elements of array.
+ valarray<_Tp>& operator|=(const valarray<_Tp>&);
+
+ /// Logical and corresponding elements of @a v with elements of array.
+ valarray<_Tp>& operator&=(const valarray<_Tp>&);
+
+ /// Left shift elements of array by corresponding elements of @a v.
+ valarray<_Tp>& operator<<=(const valarray<_Tp>&);
+
+ /// Right shift elements of array by corresponding elements of @a v.
+ valarray<_Tp>& operator>>=(const valarray<_Tp>&);
+
+ template<class _Dom>
+ valarray<_Tp>& operator*=(const _Expr<_Dom, _Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator/=(const _Expr<_Dom, _Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator%=(const _Expr<_Dom, _Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator+=(const _Expr<_Dom, _Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator-=(const _Expr<_Dom, _Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator^=(const _Expr<_Dom, _Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator|=(const _Expr<_Dom, _Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator&=(const _Expr<_Dom, _Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator<<=(const _Expr<_Dom, _Tp>&);
+ template<class _Dom>
+ valarray<_Tp>& operator>>=(const _Expr<_Dom, _Tp>&);
+
+ // _lib.valarray.members_ member functions:
+#if __cplusplus >= 201103L
+ /// Swap.
+ void swap(valarray<_Tp>& __v) noexcept;
+#endif
+
+ /// Return the number of elements in array.
+ size_t size() const;
+
+ /**
+ * @brief Return the sum of all elements in the array.
+ *
+ * Accumulates the sum of all elements into a Tp using +=. The order
+ * of adding the elements is unspecified.
+ */
+ _Tp sum() const;
+
+ /// Return the minimum element using operator<().
+ _Tp min() const;
+
+ /// Return the maximum element using operator<().
+ _Tp max() const;
+
+ /**
+ * @brief Return a shifted array.
+ *
+ * A new valarray is constructed as a copy of this array with elements
+ * in shifted positions. For an element with index i, the new position
+ * is i - n. The new valarray has the same size as the current one.
+ * New elements without a value are set to 0. Elements whose new
+ * position is outside the bounds of the array are discarded.
+ *
+ * Positive arguments shift toward index 0, discarding elements [0, n).
+ * Negative arguments discard elements from the top of the array.
+ *
+ * @param __n Number of element positions to shift.
+ * @return New valarray with elements in shifted positions.
+ */
+ valarray<_Tp> shift (int __n) const;
+
+ /**
+ * @brief Return a rotated array.
+ *
+ * A new valarray is constructed as a copy of this array with elements
+ * in shifted positions. For an element with index i, the new position
+ * is (i - n) % size(). The new valarray has the same size as the
+ * current one. Elements that are shifted beyond the array bounds are
+ * shifted into the other end of the array. No elements are lost.
+ *
+ * Positive arguments shift toward index 0, wrapping around the top.
+ * Negative arguments shift towards the top, wrapping around to 0.
+ *
+ * @param __n Number of element positions to rotate.
+ * @return New valarray with elements in shifted positions.
+ */
+ valarray<_Tp> cshift(int __n) const;
+
+ /**
+ * @brief Apply a function to the array.
+ *
+ * Returns a new valarray with elements assigned to the result of
+ * applying func to the corresponding element of this array. The new
+ * array has the same size as this one.
+ *
+ * @param func Function of Tp returning Tp to apply.
+ * @return New valarray with transformed elements.
+ */
+ _Expr<_ValFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(_Tp)) const;
+
+ /**
+ * @brief Apply a function to the array.
+ *
+ * Returns a new valarray with elements assigned to the result of
+ * applying func to the corresponding element of this array. The new
+ * array has the same size as this one.
+ *
+ * @param func Function of const Tp& returning Tp to apply.
+ * @return New valarray with transformed elements.
+ */
+ _Expr<_RefFunClos<_ValArray, _Tp>, _Tp> apply(_Tp func(const _Tp&)) const;
+
+ /**
+ * @brief Resize array.
+ *
+ * Resize this array to @a size and set all elements to @a c. All
+ * references and iterators are invalidated.
+ *
+ * @param __size New array size.
+ * @param __c New value for all elements.
+ */
+ void resize(size_t __size, _Tp __c = _Tp());
+
+ private:
+ size_t _M_size;
+ _Tp* __restrict__ _M_data;
+
+ friend class _Array<_Tp>;
+ };
+
+ template<typename _Tp>
+ inline const _Tp&
+ valarray<_Tp>::operator[](size_t __i) const
+ {
+ __glibcxx_requires_subscript(__i);
+ return _M_data[__i];
+ }
+
+ template<typename _Tp>
+ inline _Tp&
+ valarray<_Tp>::operator[](size_t __i)
+ {
+ __glibcxx_requires_subscript(__i);
+ return _M_data[__i];
+ }
+
+ // @} group numeric_arrays
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#include <bits/valarray_after.h>
+#include <bits/slice_array.h>
+#include <bits/gslice.h>
+#include <bits/gslice_array.h>
+#include <bits/mask_array.h>
+#include <bits/indirect_array.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ /**
+ * @addtogroup numeric_arrays
+ * @{
+ */
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray() : _M_size(0), _M_data(0) {}
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(size_t __n)
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ { std::__valarray_default_construct(_M_data, _M_data + __n); }
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(const _Tp& __t, size_t __n)
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ { std::__valarray_fill_construct(_M_data, _M_data + __n, __t); }
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(const _Tp* __restrict__ __p, size_t __n)
+ : _M_size(__n), _M_data(__valarray_get_storage<_Tp>(__n))
+ {
+ _GLIBCXX_DEBUG_ASSERT(__p != 0 || __n == 0);
+ std::__valarray_copy_construct(__p, __p + __n, _M_data);
+ }
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(const valarray<_Tp>& __v)
+ : _M_size(__v._M_size), _M_data(__valarray_get_storage<_Tp>(__v._M_size))
+ { std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size,
+ _M_data); }
+
+#if __cplusplus >= 201103L
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(valarray<_Tp>&& __v) noexcept
+ : _M_size(__v._M_size), _M_data(__v._M_data)
+ {
+ __v._M_size = 0;
+ __v._M_data = 0;
+ }
+#endif
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(const slice_array<_Tp>& __sa)
+ : _M_size(__sa._M_sz), _M_data(__valarray_get_storage<_Tp>(__sa._M_sz))
+ {
+ std::__valarray_copy_construct
+ (__sa._M_array, __sa._M_sz, __sa._M_stride, _Array<_Tp>(_M_data));
+ }
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(const gslice_array<_Tp>& __ga)
+ : _M_size(__ga._M_index.size()),
+ _M_data(__valarray_get_storage<_Tp>(_M_size))
+ {
+ std::__valarray_copy_construct
+ (__ga._M_array, _Array<size_t>(__ga._M_index),
+ _Array<_Tp>(_M_data), _M_size);
+ }
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(const mask_array<_Tp>& __ma)
+ : _M_size(__ma._M_sz), _M_data(__valarray_get_storage<_Tp>(__ma._M_sz))
+ {
+ std::__valarray_copy_construct
+ (__ma._M_array, __ma._M_mask, _Array<_Tp>(_M_data), _M_size);
+ }
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(const indirect_array<_Tp>& __ia)
+ : _M_size(__ia._M_sz), _M_data(__valarray_get_storage<_Tp>(__ia._M_sz))
+ {
+ std::__valarray_copy_construct
+ (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size);
+ }
+
+#if __cplusplus >= 201103L
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::valarray(initializer_list<_Tp> __l)
+ : _M_size(__l.size()), _M_data(__valarray_get_storage<_Tp>(__l.size()))
+ { std::__valarray_copy_construct(__l.begin(), __l.end(), _M_data); }
+#endif
+
+ template<typename _Tp> template<class _Dom>
+ inline
+ valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e)
+ : _M_size(__e.size()), _M_data(__valarray_get_storage<_Tp>(_M_size))
+ { std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data)); }
+
+ template<typename _Tp>
+ inline
+ valarray<_Tp>::~valarray() _GLIBCXX_NOEXCEPT
+ {
+ std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
+ std::__valarray_release_memory(_M_data);
+ }
+
+ template<typename _Tp>
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const valarray<_Tp>& __v)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 630. arrays of valarray.
+ if (_M_size == __v._M_size)
+ std::__valarray_copy(__v._M_data, _M_size, _M_data);
+ else
+ {
+ if (_M_data)
+ {
+ std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
+ std::__valarray_release_memory(_M_data);
+ }
+ _M_size = __v._M_size;
+ _M_data = __valarray_get_storage<_Tp>(_M_size);
+ std::__valarray_copy_construct(__v._M_data, __v._M_data + _M_size,
+ _M_data);
+ }
+ return *this;
+ }
+
+#if __cplusplus >= 201103L
+ template<typename _Tp>
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(valarray<_Tp>&& __v) noexcept
+ {
+ if (_M_data)
+ {
+ std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
+ std::__valarray_release_memory(_M_data);
+ }
+ _M_size = __v._M_size;
+ _M_data = __v._M_data;
+ __v._M_size = 0;
+ __v._M_data = 0;
+ return *this;
+ }
+
+ template<typename _Tp>
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(initializer_list<_Tp> __l)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 630. arrays of valarray.
+ if (_M_size == __l.size())
+ std::__valarray_copy(__l.begin(), __l.size(), _M_data);
+ else
+ {
+ if (_M_data)
+ {
+ std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
+ std::__valarray_release_memory(_M_data);
+ }
+ _M_size = __l.size();
+ _M_data = __valarray_get_storage<_Tp>(_M_size);
+ std::__valarray_copy_construct(__l.begin(), __l.begin() + _M_size,
+ _M_data);
+ }
+ return *this;
+ }
+#endif
+
+ template<typename _Tp>
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const _Tp& __t)
+ {
+ std::__valarray_fill(_M_data, _M_size, __t);
+ return *this;
+ }
+
+ template<typename _Tp>
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const slice_array<_Tp>& __sa)
+ {
+ _GLIBCXX_DEBUG_ASSERT(_M_size == __sa._M_sz);
+ std::__valarray_copy(__sa._M_array, __sa._M_sz,
+ __sa._M_stride, _Array<_Tp>(_M_data));
+ return *this;
+ }
+
+ template<typename _Tp>
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const gslice_array<_Tp>& __ga)
+ {
+ _GLIBCXX_DEBUG_ASSERT(_M_size == __ga._M_index.size());
+ std::__valarray_copy(__ga._M_array, _Array<size_t>(__ga._M_index),
+ _Array<_Tp>(_M_data), _M_size);
+ return *this;
+ }
+
+ template<typename _Tp>
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const mask_array<_Tp>& __ma)
+ {
+ _GLIBCXX_DEBUG_ASSERT(_M_size == __ma._M_sz);
+ std::__valarray_copy(__ma._M_array, __ma._M_mask,
+ _Array<_Tp>(_M_data), _M_size);
+ return *this;
+ }
+
+ template<typename _Tp>
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const indirect_array<_Tp>& __ia)
+ {
+ _GLIBCXX_DEBUG_ASSERT(_M_size == __ia._M_sz);
+ std::__valarray_copy(__ia._M_array, __ia._M_index,
+ _Array<_Tp>(_M_data), _M_size);
+ return *this;
+ }
+
+ template<typename _Tp> template<class _Dom>
+ inline valarray<_Tp>&
+ valarray<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e)
+ {
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 630. arrays of valarray.
+ if (_M_size == __e.size())
+ std::__valarray_copy(__e, _M_size, _Array<_Tp>(_M_data));
+ else
+ {
+ if (_M_data)
+ {
+ std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
+ std::__valarray_release_memory(_M_data);
+ }
+ _M_size = __e.size();
+ _M_data = __valarray_get_storage<_Tp>(_M_size);
+ std::__valarray_copy_construct(__e, _M_size, _Array<_Tp>(_M_data));
+ }
+ return *this;
+ }
+
+ template<typename _Tp>
+ inline _Expr<_SClos<_ValArray,_Tp>, _Tp>
+ valarray<_Tp>::operator[](slice __s) const
+ {
+ typedef _SClos<_ValArray,_Tp> _Closure;
+ return _Expr<_Closure, _Tp>(_Closure (_Array<_Tp>(_M_data), __s));
+ }
+
+ template<typename _Tp>
+ inline slice_array<_Tp>
+ valarray<_Tp>::operator[](slice __s)
+ { return slice_array<_Tp>(_Array<_Tp>(_M_data), __s); }
+
+ template<typename _Tp>
+ inline _Expr<_GClos<_ValArray,_Tp>, _Tp>
+ valarray<_Tp>::operator[](const gslice& __gs) const
+ {
+ typedef _GClos<_ValArray,_Tp> _Closure;
+ return _Expr<_Closure, _Tp>
+ (_Closure(_Array<_Tp>(_M_data), __gs._M_index->_M_index));
+ }
+
+ template<typename _Tp>
+ inline gslice_array<_Tp>
+ valarray<_Tp>::operator[](const gslice& __gs)
+ {
+ return gslice_array<_Tp>
+ (_Array<_Tp>(_M_data), __gs._M_index->_M_index);
+ }
+
+ template<typename _Tp>
+ inline valarray<_Tp>
+ valarray<_Tp>::operator[](const valarray<bool>& __m) const
+ {
+ size_t __s = 0;
+ size_t __e = __m.size();
+ for (size_t __i=0; __i<__e; ++__i)
+ if (__m[__i]) ++__s;
+ return valarray<_Tp>(mask_array<_Tp>(_Array<_Tp>(_M_data), __s,
+ _Array<bool> (__m)));
+ }
+
+ template<typename _Tp>
+ inline mask_array<_Tp>
+ valarray<_Tp>::operator[](const valarray<bool>& __m)
+ {
+ size_t __s = 0;
+ size_t __e = __m.size();
+ for (size_t __i=0; __i<__e; ++__i)
+ if (__m[__i]) ++__s;
+ return mask_array<_Tp>(_Array<_Tp>(_M_data), __s, _Array<bool>(__m));
+ }
+
+ template<typename _Tp>
+ inline _Expr<_IClos<_ValArray,_Tp>, _Tp>
+ valarray<_Tp>::operator[](const valarray<size_t>& __i) const
+ {
+ typedef _IClos<_ValArray,_Tp> _Closure;
+ return _Expr<_Closure, _Tp>(_Closure(*this, __i));
+ }
+
+ template<typename _Tp>
+ inline indirect_array<_Tp>
+ valarray<_Tp>::operator[](const valarray<size_t>& __i)
+ {
+ return indirect_array<_Tp>(_Array<_Tp>(_M_data), __i.size(),
+ _Array<size_t>(__i));
+ }
+
+#if __cplusplus >= 201103L
+ template<class _Tp>
+ inline void
+ valarray<_Tp>::swap(valarray<_Tp>& __v) noexcept
+ {
+ std::swap(_M_size, __v._M_size);
+ std::swap(_M_data, __v._M_data);
+ }
+#endif
+
+ template<class _Tp>
+ inline size_t
+ valarray<_Tp>::size() const
+ { return _M_size; }
+
+ template<class _Tp>
+ inline _Tp
+ valarray<_Tp>::sum() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
+ return std::__valarray_sum(_M_data, _M_data + _M_size);
+ }
+
+ template<class _Tp>
+ inline valarray<_Tp>
+ valarray<_Tp>::shift(int __n) const
+ {
+ valarray<_Tp> __ret;
+
+ if (_M_size == 0)
+ return __ret;
+
+ _Tp* __restrict__ __tmp_M_data =
+ std::__valarray_get_storage<_Tp>(_M_size);
+
+ if (__n == 0)
+ std::__valarray_copy_construct(_M_data,
+ _M_data + _M_size, __tmp_M_data);
+ else if (__n > 0) // shift left
+ {
+ if (size_t(__n) > _M_size)
+ __n = int(_M_size);
+
+ std::__valarray_copy_construct(_M_data + __n,
+ _M_data + _M_size, __tmp_M_data);
+ std::__valarray_default_construct(__tmp_M_data + _M_size - __n,
+ __tmp_M_data + _M_size);
+ }
+ else // shift right
+ {
+ if (-size_t(__n) > _M_size)
+ __n = -int(_M_size);
+
+ std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
+ __tmp_M_data - __n);
+ std::__valarray_default_construct(__tmp_M_data,
+ __tmp_M_data - __n);
+ }
+
+ __ret._M_size = _M_size;
+ __ret._M_data = __tmp_M_data;
+ return __ret;
+ }
+
+ template<class _Tp>
+ inline valarray<_Tp>
+ valarray<_Tp>::cshift(int __n) const
+ {
+ valarray<_Tp> __ret;
+
+ if (_M_size == 0)
+ return __ret;
+
+ _Tp* __restrict__ __tmp_M_data =
+ std::__valarray_get_storage<_Tp>(_M_size);
+
+ if (__n == 0)
+ std::__valarray_copy_construct(_M_data,
+ _M_data + _M_size, __tmp_M_data);
+ else if (__n > 0) // cshift left
+ {
+ if (size_t(__n) > _M_size)
+ __n = int(__n % _M_size);
+
+ std::__valarray_copy_construct(_M_data, _M_data + __n,
+ __tmp_M_data + _M_size - __n);
+ std::__valarray_copy_construct(_M_data + __n, _M_data + _M_size,
+ __tmp_M_data);
+ }
+ else // cshift right
+ {
+ if (-size_t(__n) > _M_size)
+ __n = -int(-size_t(__n) % _M_size);
+
+ std::__valarray_copy_construct(_M_data + _M_size + __n,
+ _M_data + _M_size, __tmp_M_data);
+ std::__valarray_copy_construct(_M_data, _M_data + _M_size + __n,
+ __tmp_M_data - __n);
+ }
+
+ __ret._M_size = _M_size;
+ __ret._M_data = __tmp_M_data;
+ return __ret;
+ }
+
+ template<class _Tp>
+ inline void
+ valarray<_Tp>::resize(size_t __n, _Tp __c)
+ {
+ // This complication is so to make valarray<valarray<T> > work
+ // even though it is not required by the standard. Nobody should
+ // be saying valarray<valarray<T> > anyway. See the specs.
+ std::__valarray_destroy_elements(_M_data, _M_data + _M_size);
+ if (_M_size != __n)
+ {
+ std::__valarray_release_memory(_M_data);
+ _M_size = __n;
+ _M_data = __valarray_get_storage<_Tp>(__n);
+ }
+ std::__valarray_fill_construct(_M_data, _M_data + __n, __c);
+ }
+
+ template<typename _Tp>
+ inline _Tp
+ valarray<_Tp>::min() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
+ return *std::min_element(_M_data, _M_data + _M_size);
+ }
+
+ template<typename _Tp>
+ inline _Tp
+ valarray<_Tp>::max() const
+ {
+ _GLIBCXX_DEBUG_ASSERT(_M_size > 0);
+ return *std::max_element(_M_data, _M_data + _M_size);
+ }
+
+ template<class _Tp>
+ inline _Expr<_ValFunClos<_ValArray, _Tp>, _Tp>
+ valarray<_Tp>::apply(_Tp func(_Tp)) const
+ {
+ typedef _ValFunClos<_ValArray, _Tp> _Closure;
+ return _Expr<_Closure, _Tp>(_Closure(*this, func));
+ }
+
+ template<class _Tp>
+ inline _Expr<_RefFunClos<_ValArray, _Tp>, _Tp>
+ valarray<_Tp>::apply(_Tp func(const _Tp &)) const
+ {
+ typedef _RefFunClos<_ValArray, _Tp> _Closure;
+ return _Expr<_Closure, _Tp>(_Closure(*this, func));
+ }
+
+#define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name) \
+ template<typename _Tp> \
+ inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt \
+ valarray<_Tp>::operator _Op() const \
+ { \
+ typedef _UnClos<_Name, _ValArray, _Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Rt>(_Closure(*this)); \
+ }
+
+ _DEFINE_VALARRAY_UNARY_OPERATOR(+, __unary_plus)
+ _DEFINE_VALARRAY_UNARY_OPERATOR(-, __negate)
+ _DEFINE_VALARRAY_UNARY_OPERATOR(~, __bitwise_not)
+ _DEFINE_VALARRAY_UNARY_OPERATOR (!, __logical_not)
+
+#undef _DEFINE_VALARRAY_UNARY_OPERATOR
+
+#define _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(_Op, _Name) \
+ template<class _Tp> \
+ inline valarray<_Tp>& \
+ valarray<_Tp>::operator _Op##=(const _Tp &__t) \
+ { \
+ _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, __t); \
+ return *this; \
+ } \
+ \
+ template<class _Tp> \
+ inline valarray<_Tp>& \
+ valarray<_Tp>::operator _Op##=(const valarray<_Tp> &__v) \
+ { \
+ _GLIBCXX_DEBUG_ASSERT(_M_size == __v._M_size); \
+ _Array_augmented_##_Name(_Array<_Tp>(_M_data), _M_size, \
+ _Array<_Tp>(__v._M_data)); \
+ return *this; \
+ }
+
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(+, __plus)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(-, __minus)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(*, __multiplies)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(/, __divides)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(%, __modulus)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(^, __bitwise_xor)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(&, __bitwise_and)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(|, __bitwise_or)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(<<, __shift_left)
+_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT(>>, __shift_right)
+
+#undef _DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT
+
+#define _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(_Op, _Name) \
+ template<class _Tp> template<class _Dom> \
+ inline valarray<_Tp>& \
+ valarray<_Tp>::operator _Op##=(const _Expr<_Dom, _Tp>& __e) \
+ { \
+ _Array_augmented_##_Name(_Array<_Tp>(_M_data), __e, _M_size); \
+ return *this; \
+ }
+
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(+, __plus)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(-, __minus)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(*, __multiplies)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(/, __divides)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(%, __modulus)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(^, __bitwise_xor)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(&, __bitwise_and)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(|, __bitwise_or)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(<<, __shift_left)
+_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT(>>, __shift_right)
+
+#undef _DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT
+
+
+#define _DEFINE_BINARY_OPERATOR(_Op, _Name) \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp>, \
+ typename __fun<_Name, _Tp>::result_type> \
+ operator _Op(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \
+ { \
+ _GLIBCXX_DEBUG_ASSERT(__v.size() == __w.size()); \
+ typedef _BinClos<_Name, _ValArray, _ValArray, _Tp, _Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Rt>(_Closure(__v, __w)); \
+ } \
+ \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<_Name, _ValArray,_Constant, _Tp, _Tp>, \
+ typename __fun<_Name, _Tp>::result_type> \
+ operator _Op(const valarray<_Tp>& __v, const _Tp& __t) \
+ { \
+ typedef _BinClos<_Name, _ValArray, _Constant, _Tp, _Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Rt>(_Closure(__v, __t)); \
+ } \
+ \
+ template<typename _Tp> \
+ inline _Expr<_BinClos<_Name, _Constant, _ValArray, _Tp, _Tp>, \
+ typename __fun<_Name, _Tp>::result_type> \
+ operator _Op(const _Tp& __t, const valarray<_Tp>& __v) \
+ { \
+ typedef _BinClos<_Name, _Constant, _ValArray, _Tp, _Tp> _Closure; \
+ typedef typename __fun<_Name, _Tp>::result_type _Rt; \
+ return _Expr<_Closure, _Rt>(_Closure(__t, __v)); \
+ }
+
+_DEFINE_BINARY_OPERATOR(+, __plus)
+_DEFINE_BINARY_OPERATOR(-, __minus)
+_DEFINE_BINARY_OPERATOR(*, __multiplies)
+_DEFINE_BINARY_OPERATOR(/, __divides)
+_DEFINE_BINARY_OPERATOR(%, __modulus)
+_DEFINE_BINARY_OPERATOR(^, __bitwise_xor)
+_DEFINE_BINARY_OPERATOR(&, __bitwise_and)
+_DEFINE_BINARY_OPERATOR(|, __bitwise_or)
+_DEFINE_BINARY_OPERATOR(<<, __shift_left)
+_DEFINE_BINARY_OPERATOR(>>, __shift_right)
+_DEFINE_BINARY_OPERATOR(&&, __logical_and)
+_DEFINE_BINARY_OPERATOR(||, __logical_or)
+_DEFINE_BINARY_OPERATOR(==, __equal_to)
+_DEFINE_BINARY_OPERATOR(!=, __not_equal_to)
+_DEFINE_BINARY_OPERATOR(<, __less)
+_DEFINE_BINARY_OPERATOR(>, __greater)
+_DEFINE_BINARY_OPERATOR(<=, __less_equal)
+_DEFINE_BINARY_OPERATOR(>=, __greater_equal)
+
+#undef _DEFINE_BINARY_OPERATOR
+
+#if __cplusplus >= 201103L
+ /**
+ * @brief Return an iterator pointing to the first element of
+ * the valarray.
+ * @param __va valarray.
+ */
+ template<class _Tp>
+ inline _Tp*
+ begin(valarray<_Tp>& __va)
+ { return std::__addressof(__va[0]); }
+
+ /**
+ * @brief Return an iterator pointing to the first element of
+ * the const valarray.
+ * @param __va valarray.
+ */
+ template<class _Tp>
+ inline const _Tp*
+ begin(const valarray<_Tp>& __va)
+ { return std::__addressof(__va[0]); }
+
+ /**
+ * @brief Return an iterator pointing to one past the last element of
+ * the valarray.
+ * @param __va valarray.
+ */
+ template<class _Tp>
+ inline _Tp*
+ end(valarray<_Tp>& __va)
+ { return std::__addressof(__va[0]) + __va.size(); }
+
+ /**
+ * @brief Return an iterator pointing to one past the last element of
+ * the const valarray.
+ * @param __va valarray.
+ */
+ template<class _Tp>
+ inline const _Tp*
+ end(const valarray<_Tp>& __va)
+ { return std::__addressof(__va[0]) + __va.size(); }
+#endif // C++11
+
+ // @} group numeric_arrays
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#endif /* _GLIBCXX_VALARRAY */
diff --git a/gcc-4.9/libstdc++-v3/include/std/vector b/gcc-4.9/libstdc++-v3/include/std/vector
new file mode 100644
index 0000000..c00fbc1
--- /dev/null
+++ b/gcc-4.9/libstdc++-v3/include/std/vector
@@ -0,0 +1,81 @@
+// <vector> -*- C++ -*-
+
+// Copyright (C) 2001-2014 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/>.
+
+/*
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1996
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation. Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+/** @file include/vector
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_VECTOR
+#define _GLIBCXX_VECTOR 1
+
+#pragma GCC system_header
+
+#include <bits/stl_algobase.h>
+#include <bits/allocator.h>
+#include <bits/stl_construct.h>
+#include <bits/stl_uninitialized.h>
+#include <bits/stl_vector.h>
+#include <bits/stl_bvector.h>
+#include <bits/range_access.h>
+
+#ifndef _GLIBCXX_EXPORT_TEMPLATE
+# include <bits/vector.tcc>
+#endif
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/vector>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/vector>
+#endif
+
+#endif /* _GLIBCXX_VECTOR */
+