Blame SOURCES/kyotocabinet-1.2.76-tr1_hashtable.patch

b0c39e
Workaround by Robert Scheck <robert@fedoraproject.org> for kyotocabinet >= 1.2.76, which
b0c39e
avoids the "error: declaration of 'struct std::tr1::hash<long long int>'" compile errors
b0c39e
when using GCC 4.1.x on Red Hat Enterprise Linux 5 instead of using recommented GCC 4.4.x
b0c39e
(or later) by copying and patching the relevant "/usr/include/c++/4.1.1/tr1/functional"
b0c39e
file. Passing "long long" and "unsigned long long" to tr1_hashtable_define_trivial_hash()
b0c39e
is the key. For further information, also have a look to Red Hat Bugzilla, bug ID #915123:
b0c39e
https://bugzilla.redhat.com/show_bug.cgi?id=915123
b0c39e
b0c39e
--- kyotocabinet-1.2.76/configure			2012-05-24 13:31:45.000000000 +0200
b0c39e
+++ kyotocabinet-1.2.76/configure.tr1_hashtable		2013-11-17 03:11:59.000000000 +0100
b0c39e
@@ -2090,7 +2090,7 @@
b0c39e
 
b0c39e
 # Targets
b0c39e
 MYHEADERFILES="kccommon.h kcutil.h kcthread.h kcfile.h"
b0c39e
-MYHEADERFILES="$MYHEADERFILES kccompress.h kccompare.h kcmap.h kcregex.h"
b0c39e
+MYHEADERFILES="$MYHEADERFILES kccompress.h kccompare.h kcmap.h kcregex.h kcfunctional.h"
b0c39e
 MYHEADERFILES="$MYHEADERFILES kcdb.h kcplantdb.h kcprotodb.h kcstashdb.h kccachedb.h"
b0c39e
 MYHEADERFILES="$MYHEADERFILES kchashdb.h kcdirdb.h kctextdb.h kcpolydb.h kcdbext.h kclangc.h"
b0c39e
 MYLIBRARYFILES="libkyotocabinet.a"
b0c39e
--- kyotocabinet-1.2.76/configure.in			2012-05-24 13:31:42.000000000 +0200
b0c39e
+++ kyotocabinet-1.2.76/configure.in.tr1_hashtable	2013-11-17 03:12:07.000000000 +0100
b0c39e
@@ -16,7 +16,7 @@
b0c39e
 
b0c39e
 # Targets
b0c39e
 MYHEADERFILES="kccommon.h kcutil.h kcthread.h kcfile.h"
b0c39e
-MYHEADERFILES="$MYHEADERFILES kccompress.h kccompare.h kcmap.h kcregex.h"
b0c39e
+MYHEADERFILES="$MYHEADERFILES kccompress.h kccompare.h kcmap.h kcregex.h kcfunctional.h"
b0c39e
 MYHEADERFILES="$MYHEADERFILES kcdb.h kcplantdb.h kcprotodb.h kcstashdb.h kccachedb.h"
b0c39e
 MYHEADERFILES="$MYHEADERFILES kchashdb.h kcdirdb.h kctextdb.h kcpolydb.h kcdbext.h kclangc.h"
b0c39e
 MYLIBRARYFILES="libkyotocabinet.a"
b0c39e
--- kyotocabinet-1.2.76/kccommon.h			2012-05-24 18:27:59.000000000 +0200
b0c39e
+++ kyotocabinet-1.2.76/kccommon.h.tr1_hashtable	2013-03-01 00:09:59.000000000 +0100
b0c39e
@@ -44,7 +44,7 @@
b0c39e
 #include <typeinfo>
b0c39e
 
b0c39e
 #include <utility>
b0c39e
-#include <functional>
b0c39e
+#include <kcfunctional.h>
b0c39e
 #include <memory>
b0c39e
 #include <iterator>
b0c39e
 #include <algorithm>
b0c39e
--- kyotocabinet-1.2.76/kcfunctional.h			1970-01-01 01:00:00.000000000 +0100
b0c39e
+++ kyotocabinet-1.2.76/kcfunctional.h.tr1_hashtable	2013-03-01 00:06:28.000000000 +0100
b0c39e
@@ -0,0 +1,1282 @@
b0c39e
+// TR1 functional header -*- C++ -*-
b0c39e
+
b0c39e
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
b0c39e
+//
b0c39e
+// This file is part of the GNU ISO C++ Library.  This library is free
b0c39e
+// software; you can redistribute it and/or modify it under the
b0c39e
+// terms of the GNU General Public License as published by the
b0c39e
+// Free Software Foundation; either version 2, or (at your option)
b0c39e
+// any later version.
b0c39e
+
b0c39e
+// This library is distributed in the hope that it will be useful,
b0c39e
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
b0c39e
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b0c39e
+// GNU General Public License for more details.
b0c39e
+
b0c39e
+// You should have received a copy of the GNU General Public License along
b0c39e
+// with this library; see the file COPYING.  If not, write to the Free
b0c39e
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
b0c39e
+// USA.
b0c39e
+
b0c39e
+// As a special exception, you may use this file as part of a free software
b0c39e
+// library without restriction.  Specifically, if other files instantiate
b0c39e
+// templates or use macros or inline functions from this file, or you compile
b0c39e
+// this file and link it with other files to produce an executable, this
b0c39e
+// file does not by itself cause the resulting executable to be covered by
b0c39e
+// the GNU General Public License.  This exception does not however
b0c39e
+// invalidate any other reasons why the executable file might be covered by
b0c39e
+// the GNU General Public License.
b0c39e
+
b0c39e
+/** @file
b0c39e
+ *  This is a TR1 C++ Library header.
b0c39e
+ */
b0c39e
+
b0c39e
+#ifndef _TR1_FUNCTIONAL
b0c39e
+#define _TR1_FUNCTIONAL 1
b0c39e
+
b0c39e
+#pragma GCC system_header
b0c39e
+
b0c39e
+#include "../functional"
b0c39e
+#include <typeinfo>
b0c39e
+#include <tr1/type_traits>
b0c39e
+#include <bits/cpp_type_traits.h>
b0c39e
+#include <string>               // for std::tr1::hash
b0c39e
+#include <cstdlib>              // for std::abort
b0c39e
+#include <cmath>                // for std::frexp
b0c39e
+#include <tr1/tuple>
b0c39e
+
b0c39e
+namespace std
b0c39e
+{
b0c39e
+namespace tr1
b0c39e
+{
b0c39e
+  template<typename _MemberPointer>
b0c39e
+    class _Mem_fn;
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Actual implementation of _Has_result_type, which uses SFINAE to
b0c39e
+   *  determine if the type _Tp has a publicly-accessible member type
b0c39e
+   *  result_type.
b0c39e
+   *  @endif
b0c39e
+  */
b0c39e
+  template<typename _Tp>
b0c39e
+    class _Has_result_type_helper : __sfinae_types
b0c39e
+    {
b0c39e
+      template<typename _Up>
b0c39e
+      struct _Wrap_type
b0c39e
+      { };
b0c39e
+
b0c39e
+      template<typename _Up>
b0c39e
+        static __one __test(_Wrap_type<typename _Up::result_type>*);
b0c39e
+
b0c39e
+      template<typename _Up>
b0c39e
+        static __two __test(...);
b0c39e
+
b0c39e
+    public:
b0c39e
+      static const bool value = sizeof(__test<_Tp>(0)) == 1;
b0c39e
+    };
b0c39e
+
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Has_result_type
b0c39e
+       : integral_constant<
b0c39e
+           bool,
b0c39e
+           _Has_result_type_helper<typename remove_cv<_Tp>::type>::value>
b0c39e
+    { };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  If we have found a result_type, extract it.
b0c39e
+   *  @endif
b0c39e
+  */
b0c39e
+  template<bool _Has_result_type, typename _Functor>
b0c39e
+    struct _Maybe_get_result_type
b0c39e
+    { };
b0c39e
+
b0c39e
+  template<typename _Functor>
b0c39e
+    struct _Maybe_get_result_type<true, _Functor>
b0c39e
+    {
b0c39e
+      typedef typename _Functor::result_type result_type;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Base class for any function object that has a weak result type, as
b0c39e
+   *  defined in 3.3/3 of TR1.
b0c39e
+   *  @endif
b0c39e
+  */
b0c39e
+  template<typename _Functor>
b0c39e
+    struct _Weak_result_type_impl
b0c39e
+      : _Maybe_get_result_type<_Has_result_type<_Functor>::value, _Functor>
b0c39e
+    {
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Strip top-level cv-qualifiers from the function object and let
b0c39e
+   *  _Weak_result_type_impl perform the real work.
b0c39e
+   *  @endif
b0c39e
+  */
b0c39e
+  template<typename _Functor>
b0c39e
+    struct _Weak_result_type
b0c39e
+    : _Weak_result_type_impl<typename remove_cv<_Functor>::type>
b0c39e
+    {
b0c39e
+    };
b0c39e
+
b0c39e
+  template<typename _Signature>
b0c39e
+    class result_of;
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Actual implementation of result_of. When _Has_result_type is
b0c39e
+   *  true, gets its result from _Weak_result_type. Otherwise, uses
b0c39e
+   *  the function object's member template result to extract the
b0c39e
+   *  result type.
b0c39e
+   *  @endif
b0c39e
+  */
b0c39e
+  template<bool _Has_result_type, typename _Signature>
b0c39e
+    struct _Result_of_impl;
b0c39e
+
b0c39e
+  // Handle member data pointers using _Mem_fn's logic
b0c39e
+  template<typename _Res, typename _Class, typename _T1>
b0c39e
+    struct _Result_of_impl<false, _Res _Class::*(_T1)>
b0c39e
+    {
b0c39e
+      typedef typename _Mem_fn<_Res _Class::*>
b0c39e
+                ::template _Result_type<_T1>::type type;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Determines if the type _Tp derives from unary_function.
b0c39e
+   *  @endif
b0c39e
+  */
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Derives_from_unary_function : __sfinae_types
b0c39e
+    {
b0c39e
+    private:
b0c39e
+      template<typename _T1, typename _Res>
b0c39e
+        static __one __test(const volatile unary_function<_T1, _Res>*);
b0c39e
+
b0c39e
+      // It's tempting to change "..." to const volatile void*, but
b0c39e
+      // that fails when _Tp is a function type.
b0c39e
+      static __two __test(...);
b0c39e
+
b0c39e
+    public:
b0c39e
+      static const bool value = sizeof(__test((_Tp*)0)) == 1;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Determines if the type _Tp derives from binary_function.
b0c39e
+   *  @endif
b0c39e
+  */
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Derives_from_binary_function : __sfinae_types
b0c39e
+    {
b0c39e
+    private:
b0c39e
+      template<typename _T1, typename _T2, typename _Res>
b0c39e
+        static __one __test(const volatile binary_function<_T1, _T2, _Res>*);
b0c39e
+
b0c39e
+      // It's tempting to change "..." to const volatile void*, but
b0c39e
+      // that fails when _Tp is a function type.
b0c39e
+      static __two __test(...);
b0c39e
+
b0c39e
+    public:
b0c39e
+      static const bool value = sizeof(__test((_Tp*)0)) == 1;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Turns a function type into a function pointer type
b0c39e
+   *  @endif
b0c39e
+  */
b0c39e
+  template<typename _Tp, bool _IsFunctionType = is_function<_Tp>::value>
b0c39e
+    struct _Function_to_function_pointer
b0c39e
+    {
b0c39e
+      typedef _Tp type;
b0c39e
+    };
b0c39e
+
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Function_to_function_pointer<_Tp, true>
b0c39e
+    {
b0c39e
+      typedef _Tp* type;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Knowing which of unary_function and binary_function _Tp derives
b0c39e
+   *  from, derives from the same and ensures that reference_wrapper
b0c39e
+   *  will have a weak result type. See cases below.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template<bool _Unary, bool _Binary, typename _Tp>
b0c39e
+    struct _Reference_wrapper_base_impl;
b0c39e
+
b0c39e
+  // Not a unary_function or binary_function, so try a weak result type
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Reference_wrapper_base_impl<false, false, _Tp>
b0c39e
+      : _Weak_result_type<_Tp>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // unary_function but not binary_function
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Reference_wrapper_base_impl<true, false, _Tp>
b0c39e
+      : unary_function
b0c39e
+                       typename _Tp::result_type>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // binary_function but not unary_function
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Reference_wrapper_base_impl<false, true, _Tp>
b0c39e
+      : binary_function
b0c39e
+                        typename _Tp::second_argument_type,
b0c39e
+                        typename _Tp::result_type>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // both unary_function and binary_function. import result_type to
b0c39e
+  // avoid conflicts.
b0c39e
+   template<typename _Tp>
b0c39e
+    struct _Reference_wrapper_base_impl<true, true, _Tp>
b0c39e
+      : unary_function
b0c39e
+                       typename _Tp::result_type>,
b0c39e
+        binary_function
b0c39e
+                        typename _Tp::second_argument_type,
b0c39e
+                        typename _Tp::result_type>
b0c39e
+    {
b0c39e
+      typedef typename _Tp::result_type result_type;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Derives from unary_function or binary_function when it
b0c39e
+   *  can. Specializations handle all of the easy cases. The primary
b0c39e
+   *  template determines what to do with a class type, which may
b0c39e
+   *  derive from both unary_function and binary_function.
b0c39e
+   *  @endif
b0c39e
+  */
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Reference_wrapper_base
b0c39e
+      : _Reference_wrapper_base_impl<
b0c39e
+          _Derives_from_unary_function<_Tp>::value,
b0c39e
+          _Derives_from_binary_function<_Tp>::value,
b0c39e
+          _Tp>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a function type (unary)
b0c39e
+  template<typename _Res, typename _T1>
b0c39e
+    struct _Reference_wrapper_base<_Res(_T1)>
b0c39e
+      : unary_function<_T1, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a function type (binary)
b0c39e
+  template<typename _Res, typename _T1, typename _T2>
b0c39e
+    struct _Reference_wrapper_base<_Res(_T1, _T2)>
b0c39e
+      : binary_function<_T1, _T2, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a function pointer type (unary)
b0c39e
+  template<typename _Res, typename _T1>
b0c39e
+    struct _Reference_wrapper_base<_Res(*)(_T1)>
b0c39e
+      : unary_function<_T1, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a function pointer type (binary)
b0c39e
+  template<typename _Res, typename _T1, typename _T2>
b0c39e
+    struct _Reference_wrapper_base<_Res(*)(_T1, _T2)>
b0c39e
+      : binary_function<_T1, _T2, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a pointer to member function type (unary, no qualifiers)
b0c39e
+  template<typename _Res, typename _T1>
b0c39e
+    struct _Reference_wrapper_base<_Res (_T1::*)()>
b0c39e
+      : unary_function<_T1*, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a pointer to member function type (binary, no qualifiers)
b0c39e
+  template<typename _Res, typename _T1, typename _T2>
b0c39e
+    struct _Reference_wrapper_base<_Res (_T1::*)(_T2)>
b0c39e
+      : binary_function<_T1*, _T2, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a pointer to member function type (unary, const)
b0c39e
+  template<typename _Res, typename _T1>
b0c39e
+    struct _Reference_wrapper_base<_Res (_T1::*)() const>
b0c39e
+      : unary_function<const _T1*, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a pointer to member function type (binary, const)
b0c39e
+  template<typename _Res, typename _T1, typename _T2>
b0c39e
+    struct _Reference_wrapper_base<_Res (_T1::*)(_T2) const>
b0c39e
+      : binary_function<const _T1*, _T2, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a pointer to member function type (unary, volatile)
b0c39e
+  template<typename _Res, typename _T1>
b0c39e
+    struct _Reference_wrapper_base<_Res (_T1::*)() volatile>
b0c39e
+      : unary_function<volatile _T1*, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a pointer to member function type (binary, volatile)
b0c39e
+  template<typename _Res, typename _T1, typename _T2>
b0c39e
+    struct _Reference_wrapper_base<_Res (_T1::*)(_T2) volatile>
b0c39e
+      : binary_function<volatile _T1*, _T2, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a pointer to member function type (unary, const volatile)
b0c39e
+  template<typename _Res, typename _T1>
b0c39e
+    struct _Reference_wrapper_base<_Res (_T1::*)() const volatile>
b0c39e
+      : unary_function<const volatile _T1*, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  // - a pointer to member function type (binary, const volatile)
b0c39e
+  template<typename _Res, typename _T1, typename _T2>
b0c39e
+    struct _Reference_wrapper_base<_Res (_T1::*)(_T2) const volatile>
b0c39e
+      : binary_function<const volatile _T1*, _T2, _Res>
b0c39e
+    { };
b0c39e
+
b0c39e
+  template<typename _Tp>
b0c39e
+    class reference_wrapper
b0c39e
+      : public _Reference_wrapper_base<typename remove_cv<_Tp>::type>
b0c39e
+    {
b0c39e
+      // If _Tp is a function type, we can't form result_of<_Tp(...)>,
b0c39e
+      // so turn it into a function pointer type.
b0c39e
+      typedef typename _Function_to_function_pointer<_Tp>::type
b0c39e
+        _M_func_type;
b0c39e
+
b0c39e
+      _Tp* _M_data;
b0c39e
+    public:
b0c39e
+      typedef _Tp type;
b0c39e
+      explicit reference_wrapper(_Tp& __indata): _M_data(&__indata)
b0c39e
+      { }
b0c39e
+
b0c39e
+      reference_wrapper(const reference_wrapper<_Tp>& __inref):
b0c39e
+      _M_data(__inref._M_data)
b0c39e
+      { }
b0c39e
+
b0c39e
+      reference_wrapper&
b0c39e
+      operator=(const reference_wrapper<_Tp>& __inref)
b0c39e
+      {
b0c39e
+        _M_data = __inref._M_data;
b0c39e
+        return *this;
b0c39e
+      }
b0c39e
+
b0c39e
+      operator _Tp&() const
b0c39e
+      { return this->get(); }
b0c39e
+
b0c39e
+      _Tp&
b0c39e
+      get() const
b0c39e
+      { return *_M_data; }
b0c39e
+
b0c39e
+#define _GLIBCXX_REPEAT_HEADER <tr1/ref_wrap_iterate.h>
b0c39e
+#include <tr1/repeat.h>
b0c39e
+#undef _GLIBCXX_REPEAT_HEADER
b0c39e
+    };
b0c39e
+
b0c39e
+
b0c39e
+  // Denotes a reference should be taken to a variable.
b0c39e
+  template<typename _Tp>
b0c39e
+    inline reference_wrapper<_Tp>
b0c39e
+    ref(_Tp& __t)
b0c39e
+    { return reference_wrapper<_Tp>(__t); }
b0c39e
+
b0c39e
+  // Denotes a const reference should be taken to a variable.
b0c39e
+  template<typename _Tp>
b0c39e
+    inline reference_wrapper<const _Tp>
b0c39e
+    cref(const _Tp& __t)
b0c39e
+    { return reference_wrapper<const _Tp>(__t); }
b0c39e
+
b0c39e
+  template<typename _Tp>
b0c39e
+    inline reference_wrapper<_Tp>
b0c39e
+    ref(reference_wrapper<_Tp> __t)
b0c39e
+    { return ref(__t.get()); }
b0c39e
+
b0c39e
+  template<typename _Tp>
b0c39e
+    inline reference_wrapper<const _Tp>
b0c39e
+    cref(reference_wrapper<_Tp> __t)
b0c39e
+    { return cref(__t.get()); }
b0c39e
+
b0c39e
+   template<typename _Tp, bool>
b0c39e
+     struct _Mem_fn_const_or_non
b0c39e
+     {
b0c39e
+       typedef const _Tp& type;
b0c39e
+     };
b0c39e
+
b0c39e
+    template<typename _Tp>
b0c39e
+      struct _Mem_fn_const_or_non<_Tp, false>
b0c39e
+      {
b0c39e
+        typedef _Tp& type;
b0c39e
+      };
b0c39e
+
b0c39e
+  template<typename _Res, typename _Class>
b0c39e
+  class _Mem_fn<_Res _Class::*>
b0c39e
+  {
b0c39e
+    // This bit of genius is due to Peter Dimov, improved slightly by
b0c39e
+    // Douglas Gregor.
b0c39e
+    template<typename _Tp>
b0c39e
+      _Res&
b0c39e
+      _M_call(_Tp& __object, _Class *) const
b0c39e
+      { return __object.*__pm; }
b0c39e
+
b0c39e
+    template<typename _Tp, typename _Up>
b0c39e
+      _Res&
b0c39e
+      _M_call(_Tp& __object, _Up * const *) const
b0c39e
+      { return (*__object).*__pm; }
b0c39e
+
b0c39e
+    template<typename _Tp, typename _Up>
b0c39e
+      const _Res&
b0c39e
+      _M_call(_Tp& __object, const _Up * const *) const
b0c39e
+      { return (*__object).*__pm; }
b0c39e
+
b0c39e
+    template<typename _Tp>
b0c39e
+      const _Res&
b0c39e
+      _M_call(_Tp& __object, const _Class *) const
b0c39e
+      { return __object.*__pm; }
b0c39e
+
b0c39e
+    template<typename _Tp>
b0c39e
+      const _Res&
b0c39e
+      _M_call(_Tp& __ptr, const volatile void*) const
b0c39e
+      { return (*__ptr).*__pm; }
b0c39e
+
b0c39e
+    template<typename _Tp> static _Tp& __get_ref();
b0c39e
+
b0c39e
+    template<typename _Tp>
b0c39e
+      static __sfinae_types::__one __check_const(_Tp&, _Class*);
b0c39e
+    template<typename _Tp, typename _Up>
b0c39e
+      static __sfinae_types::__one __check_const(_Tp&, _Up * const *);
b0c39e
+    template<typename _Tp, typename _Up>
b0c39e
+      static __sfinae_types::__two __check_const(_Tp&, const _Up * const *);
b0c39e
+    template<typename _Tp>
b0c39e
+      static __sfinae_types::__two __check_const(_Tp&, const _Class*);
b0c39e
+    template<typename _Tp>
b0c39e
+      static __sfinae_types::__two __check_const(_Tp&, const volatile void*);
b0c39e
+
b0c39e
+  public:
b0c39e
+    template<typename _Tp>
b0c39e
+      struct _Result_type
b0c39e
+        : _Mem_fn_const_or_non<
b0c39e
+            _Res,
b0c39e
+            (sizeof(__sfinae_types::__two)
b0c39e
+             == sizeof(__check_const<_Tp>(__get_ref<_Tp>(), (_Tp*)0)))>
b0c39e
+      { };
b0c39e
+
b0c39e
+    template<typename _Signature>
b0c39e
+      struct result;
b0c39e
+
b0c39e
+    template<typename _CVMem, typename _Tp>
b0c39e
+      struct result<_CVMem(_Tp)>
b0c39e
+        : public _Result_type<_Tp> { };
b0c39e
+
b0c39e
+    template<typename _CVMem, typename _Tp>
b0c39e
+      struct result<_CVMem(_Tp&)>
b0c39e
+        : public _Result_type<_Tp> { };
b0c39e
+
b0c39e
+    explicit _Mem_fn(_Res _Class::*__pm) : __pm(__pm) { }
b0c39e
+
b0c39e
+    // Handle objects
b0c39e
+    _Res&       operator()(_Class& __object)       const
b0c39e
+    { return __object.*__pm; }
b0c39e
+
b0c39e
+    const _Res& operator()(const _Class& __object) const
b0c39e
+    { return __object.*__pm; }
b0c39e
+
b0c39e
+    // Handle pointers
b0c39e
+    _Res&       operator()(_Class* __object)       const
b0c39e
+    { return __object->*__pm; }
b0c39e
+
b0c39e
+    const _Res&
b0c39e
+    operator()(const _Class* __object) const
b0c39e
+    { return __object->*__pm; }
b0c39e
+
b0c39e
+    // Handle smart pointers and derived
b0c39e
+    template<typename _Tp>
b0c39e
+      typename _Result_type<_Tp>::type
b0c39e
+      operator()(_Tp& __unknown) const
b0c39e
+      { return _M_call(__unknown, &__unknown); }
b0c39e
+
b0c39e
+  private:
b0c39e
+    _Res _Class::*__pm;
b0c39e
+  };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @brief Returns a function object that forwards to the member
b0c39e
+   *  pointer @a pm.
b0c39e
+   */
b0c39e
+  template<typename _Tp, typename _Class>
b0c39e
+    inline _Mem_fn<_Tp _Class::*>
b0c39e
+    mem_fn(_Tp _Class::* __pm)
b0c39e
+    {
b0c39e
+      return _Mem_fn<_Tp _Class::*>(__pm);
b0c39e
+    }
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @brief Determines if the given type _Tp is a function object
b0c39e
+   *  should be treated as a subexpression when evaluating calls to
b0c39e
+   *  function objects returned by bind(). [TR1 3.6.1]
b0c39e
+   */
b0c39e
+  template<typename _Tp>
b0c39e
+    struct is_bind_expression
b0c39e
+    {
b0c39e
+      static const bool value = false;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @brief Determines if the given type _Tp is a placeholder in a
b0c39e
+   *  bind() expression and, if so, which placeholder it is. [TR1 3.6.2]
b0c39e
+   */
b0c39e
+  template<typename _Tp>
b0c39e
+    struct is_placeholder
b0c39e
+    {
b0c39e
+      static const int value = 0;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  The type of placeholder objects defined by libstdc++.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template<int _Num> struct _Placeholder { };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Partial specialization of is_placeholder that provides the placeholder
b0c39e
+   *  number for the placeholder objects defined by libstdc++.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template<int _Num>
b0c39e
+    struct is_placeholder<_Placeholder<_Num> >
b0c39e
+    {
b0c39e
+      static const int value = _Num;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Maps an argument to bind() into an actual argument to the bound
b0c39e
+   *  function object [TR1 3.6.3/5]. Only the first parameter should
b0c39e
+   *  be specified: the rest are used to determine among the various
b0c39e
+   *  implementations. Note that, although this class is a function
b0c39e
+   *  object, isn't not entirely normal because it takes only two
b0c39e
+   *  parameters regardless of the number of parameters passed to the
b0c39e
+   *  bind expression. The first parameter is the bound argument and
b0c39e
+   *  the second parameter is a tuple containing references to the
b0c39e
+   *  rest of the arguments.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template
b0c39e
+           bool _IsBindExp = is_bind_expression<_Arg>::value,
b0c39e
+           bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>
b0c39e
+    class _Mu;
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  If the argument is reference_wrapper<_Tp>, returns the
b0c39e
+   *  underlying reference. [TR1 3.6.3/5 bullet 1]
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template<typename _Tp>
b0c39e
+    class _Mu<reference_wrapper<_Tp>, false, false>
b0c39e
+    {
b0c39e
+    public:
b0c39e
+      typedef _Tp& result_type;
b0c39e
+
b0c39e
+      /* Note: This won't actually work for const volatile
b0c39e
+       * reference_wrappers, because reference_wrapper::get() is const
b0c39e
+       * but not volatile-qualified. This might be a defect in the TR.
b0c39e
+       */
b0c39e
+      template<typename _CVRef, typename _Tuple>
b0c39e
+      result_type
b0c39e
+      operator()(_CVRef& __arg, const _Tuple&) const volatile
b0c39e
+      { return __arg.get(); }
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  If the argument is a bind expression, we invoke the underlying
b0c39e
+   *  function object with the same cv-qualifiers as we are given and
b0c39e
+   *  pass along all of our arguments (unwrapped). [TR1 3.6.3/5 bullet 2]
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template<typename _Arg>
b0c39e
+    class _Mu<_Arg, true, false>
b0c39e
+    {
b0c39e
+    public:
b0c39e
+      template<typename _Signature> class result;
b0c39e
+
b0c39e
+#define _GLIBCXX_REPEAT_HEADER <tr1/mu_iterate.h>
b0c39e
+#  include <tr1/repeat.h>
b0c39e
+#undef _GLIBCXX_REPEAT_HEADER
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  If the argument is a placeholder for the Nth argument, returns
b0c39e
+   *  a reference to the Nth argument to the bind function object.
b0c39e
+   *  [TR1 3.6.3/5 bullet 3]
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template<typename _Arg>
b0c39e
+    class _Mu<_Arg, false, true>
b0c39e
+    {
b0c39e
+    public:
b0c39e
+      template<typename _Signature> class result;
b0c39e
+
b0c39e
+      template<typename _CVMu, typename _CVArg, typename _Tuple>
b0c39e
+      class result<_CVMu(_CVArg, _Tuple)>
b0c39e
+      {
b0c39e
+        // Add a reference, if it hasn't already been done for us.
b0c39e
+        // This allows us to be a little bit sloppy in constructing
b0c39e
+        // the tuple that we pass to result_of<...>.
b0c39e
+        typedef typename tuple_element<(is_placeholder<_Arg>::value - 1),
b0c39e
+                                       _Tuple>::type __base_type;
b0c39e
+
b0c39e
+      public:
b0c39e
+        typedef typename add_reference<__base_type>::type type;
b0c39e
+      };
b0c39e
+
b0c39e
+      template<typename _Tuple>
b0c39e
+      typename result<_Mu(_Arg, _Tuple)>::type
b0c39e
+      operator()(const volatile _Arg&, const _Tuple& __tuple) const volatile
b0c39e
+      {
b0c39e
+        return ::std::tr1::get<(is_placeholder<_Arg>::value - 1)>(__tuple);
b0c39e
+      }
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  If the argument is just a value, returns a reference to that
b0c39e
+   *  value. The cv-qualifiers on the reference are the same as the
b0c39e
+   *  cv-qualifiers on the _Mu object. [TR1 3.6.3/5 bullet 4]
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template<typename _Arg>
b0c39e
+    class _Mu<_Arg, false, false>
b0c39e
+    {
b0c39e
+    public:
b0c39e
+      template<typename _Signature> struct result;
b0c39e
+
b0c39e
+      template<typename _CVMu, typename _CVArg, typename _Tuple>
b0c39e
+      struct result<_CVMu(_CVArg, _Tuple)>
b0c39e
+      {
b0c39e
+        typedef typename add_reference<_CVArg>::type type;
b0c39e
+      };
b0c39e
+
b0c39e
+      // Pick up the cv-qualifiers of the argument
b0c39e
+      template<typename _CVArg, typename _Tuple>
b0c39e
+      _CVArg& operator()(_CVArg& __arg, const _Tuple&) const volatile
b0c39e
+      { return __arg; }
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Maps member pointers into instances of _Mem_fn but leaves all
b0c39e
+   *  other function objects untouched. Used by tr1::bind(). The
b0c39e
+   *  primary template handles the non--member-pointer case.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Maybe_wrap_member_pointer
b0c39e
+    {
b0c39e
+      typedef _Tp type;
b0c39e
+      static const _Tp& __do_wrap(const _Tp& __x) { return __x; }
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Maps member pointers into instances of _Mem_fn but leaves all
b0c39e
+   *  other function objects untouched. Used by tr1::bind(). This
b0c39e
+   *  partial specialization handles the member pointer case.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  template<typename _Tp, typename _Class>
b0c39e
+    struct _Maybe_wrap_member_pointer<_Tp _Class::*>
b0c39e
+    {
b0c39e
+      typedef _Mem_fn<_Tp _Class::*> type;
b0c39e
+      static type __do_wrap(_Tp _Class::* __pm) { return type(__pm); }
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Type of the function object returned from bind().
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+   template<typename _Signature>
b0c39e
+     struct _Bind;
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Type of the function object returned from bind<R>().
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+   template<typename _Result, typename _Signature>
b0c39e
+     struct _Bind_result;
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Class template _Bind is always a bind expression.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+   template<typename _Signature>
b0c39e
+    struct is_bind_expression<_Bind<_Signature> >
b0c39e
+    {
b0c39e
+      static const bool value = true;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Class template _Bind_result is always a bind expression.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+   template<typename _Result, typename _Signature>
b0c39e
+   struct is_bind_expression<_Bind_result<_Result, _Signature> >
b0c39e
+    {
b0c39e
+      static const bool value = true;
b0c39e
+    };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @brief Exception class thrown when class template function's
b0c39e
+   *  operator() is called with an empty target.
b0c39e
+   *
b0c39e
+   */
b0c39e
+  class bad_function_call : public std::exception { };
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  The integral constant expression 0 can be converted into a
b0c39e
+   *  pointer to this type. It is used by the function template to
b0c39e
+   *  accept NULL pointers.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  struct _M_clear_type;
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Trait identifying "location-invariant" types, meaning that the
b0c39e
+   *  address of the object (or any of its members) will not escape.
b0c39e
+   *  Also implies a trivial copy constructor and assignment operator.
b0c39e
+   *   @endif
b0c39e
+   */
b0c39e
+  template<typename _Tp>
b0c39e
+    struct __is_location_invariant
b0c39e
+    : integral_constant
b0c39e
+                        (is_pointer<_Tp>::value
b0c39e
+                         || is_member_pointer<_Tp>::value)>
b0c39e
+    {
b0c39e
+    };
b0c39e
+
b0c39e
+  class _Undefined_class;
b0c39e
+
b0c39e
+  union _Nocopy_types
b0c39e
+  {
b0c39e
+    void*       _M_object;
b0c39e
+    const void* _M_const_object;
b0c39e
+    void (*_M_function_pointer)();
b0c39e
+    void (_Undefined_class::*_M_member_pointer)();
b0c39e
+  };
b0c39e
+
b0c39e
+  union _Any_data {
b0c39e
+    void*       _M_access()       { return &_M_pod_data[0]; }
b0c39e
+    const void* _M_access() const { return &_M_pod_data[0]; }
b0c39e
+
b0c39e
+    template<typename _Tp> _Tp& _M_access()
b0c39e
+    { return *static_cast<_Tp*>(_M_access()); }
b0c39e
+
b0c39e
+    template<typename _Tp> const _Tp& _M_access() const
b0c39e
+    { return *static_cast<const _Tp*>(_M_access()); }
b0c39e
+
b0c39e
+    _Nocopy_types _M_unused;
b0c39e
+    char _M_pod_data[sizeof(_Nocopy_types)];
b0c39e
+  };
b0c39e
+
b0c39e
+  enum _Manager_operation
b0c39e
+  {
b0c39e
+    __get_type_info,
b0c39e
+    __get_functor_ptr,
b0c39e
+    __clone_functor,
b0c39e
+    __destroy_functor
b0c39e
+  };
b0c39e
+
b0c39e
+  /* Simple type wrapper that helps avoid annoying const problems
b0c39e
+     when casting between void pointers and pointers-to-pointers. */
b0c39e
+  template<typename _Tp>
b0c39e
+    struct _Simple_type_wrapper
b0c39e
+    {
b0c39e
+      _Simple_type_wrapper(_Tp __value) : __value(__value) { }
b0c39e
+
b0c39e
+      _Tp __value;
b0c39e
+    };
b0c39e
+
b0c39e
+  template<typename _Tp>
b0c39e
+    struct __is_location_invariant<_Simple_type_wrapper<_Tp> >
b0c39e
+      : __is_location_invariant<_Tp>
b0c39e
+    {
b0c39e
+    };
b0c39e
+
b0c39e
+  // Converts a reference to a function object into a callable
b0c39e
+  // function object.
b0c39e
+  template<typename _Functor>
b0c39e
+    inline _Functor& __callable_functor(_Functor& __f) { return __f; }
b0c39e
+
b0c39e
+  template<typename _Member, typename _Class>
b0c39e
+    inline _Mem_fn<_Member _Class::*>
b0c39e
+    __callable_functor(_Member _Class::* &__p)
b0c39e
+    { return mem_fn(__p); }
b0c39e
+
b0c39e
+  template<typename _Member, typename _Class>
b0c39e
+    inline _Mem_fn<_Member _Class::*>
b0c39e
+    __callable_functor(_Member _Class::* const &__p)
b0c39e
+    { return mem_fn(__p); }
b0c39e
+
b0c39e
+  template<typename _Signature, typename _Functor>
b0c39e
+    class _Function_handler;
b0c39e
+
b0c39e
+  template<typename _Signature>
b0c39e
+    class function;
b0c39e
+
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @if maint
b0c39e
+   *  Base class of all polymorphic function object wrappers.
b0c39e
+   *  @endif
b0c39e
+   */
b0c39e
+  class _Function_base
b0c39e
+  {
b0c39e
+  public:
b0c39e
+    static const std::size_t _M_max_size = sizeof(_Nocopy_types);
b0c39e
+    static const std::size_t _M_max_align = __alignof__(_Nocopy_types);
b0c39e
+
b0c39e
+    template<typename _Functor>
b0c39e
+    class _Base_manager
b0c39e
+    {
b0c39e
+    protected:
b0c39e
+      static const bool __stored_locally =
b0c39e
+        (__is_location_invariant<_Functor>::value
b0c39e
+         && sizeof(_Functor) <= _M_max_size
b0c39e
+         && __alignof__(_Functor) <= _M_max_align
b0c39e
+         && (_M_max_align % __alignof__(_Functor) == 0));
b0c39e
+      typedef integral_constant<bool, __stored_locally> _Local_storage;
b0c39e
+
b0c39e
+      // Retrieve a pointer to the function object
b0c39e
+      static _Functor* _M_get_pointer(const _Any_data& __source)
b0c39e
+      {
b0c39e
+        const _Functor* __ptr =
b0c39e
+          __stored_locally? &__source._M_access<_Functor>()
b0c39e
+          /* have stored a pointer */ : __source._M_access<_Functor*>();
b0c39e
+        return const_cast<_Functor*>(__ptr);
b0c39e
+      }
b0c39e
+
b0c39e
+      // Clone a location-invariant function object that fits within
b0c39e
+      // an _Any_data structure.
b0c39e
+      static void
b0c39e
+      _M_clone(_Any_data& __dest, const _Any_data& __source, true_type)
b0c39e
+      {
b0c39e
+        new (__dest._M_access()) _Functor(__source._M_access<_Functor>());
b0c39e
+      }
b0c39e
+
b0c39e
+      // Clone a function object that is not location-invariant or
b0c39e
+      // that cannot fit into an _Any_data structure.
b0c39e
+      static void
b0c39e
+      _M_clone(_Any_data& __dest, const _Any_data& __source, false_type)
b0c39e
+      {
b0c39e
+        __dest._M_access<_Functor*>() =
b0c39e
+          new _Functor(*__source._M_access<_Functor*>());
b0c39e
+      }
b0c39e
+
b0c39e
+      // Destroying a location-invariant object may still require
b0c39e
+      // destruction.
b0c39e
+      static void
b0c39e
+      _M_destroy(_Any_data& __victim, true_type)
b0c39e
+      {
b0c39e
+        __victim._M_access<_Functor>().~_Functor();
b0c39e
+      }
b0c39e
+
b0c39e
+      // Destroying an object located on the heap.
b0c39e
+      static void
b0c39e
+      _M_destroy(_Any_data& __victim, false_type)
b0c39e
+      {
b0c39e
+        delete __victim._M_access<_Functor*>();
b0c39e
+      }
b0c39e
+
b0c39e
+    public:
b0c39e
+      static bool
b0c39e
+      _M_manager(_Any_data& __dest, const _Any_data& __source,
b0c39e
+                 _Manager_operation __op)
b0c39e
+      {
b0c39e
+        switch (__op) {
b0c39e
+        case __get_type_info:
b0c39e
+          __dest._M_access<const type_info*>() = &typeid(_Functor);
b0c39e
+          break;
b0c39e
+
b0c39e
+        case __get_functor_ptr:
b0c39e
+          __dest._M_access<_Functor*>() = _M_get_pointer(__source);
b0c39e
+          break;
b0c39e
+
b0c39e
+        case __clone_functor:
b0c39e
+          _M_clone(__dest, __source, _Local_storage());
b0c39e
+          break;
b0c39e
+
b0c39e
+        case __destroy_functor:
b0c39e
+          _M_destroy(__dest, _Local_storage());
b0c39e
+          break;
b0c39e
+        }
b0c39e
+        return false;
b0c39e
+      }
b0c39e
+
b0c39e
+      static void
b0c39e
+      _M_init_functor(_Any_data& __functor, const _Functor& __f)
b0c39e
+      {
b0c39e
+        _M_init_functor(__functor, __f, _Local_storage());
b0c39e
+      }
b0c39e
+
b0c39e
+      template<typename _Signature>
b0c39e
+      static bool
b0c39e
+      _M_not_empty_function(const function<_Signature>& __f)
b0c39e
+      {
b0c39e
+        return __f;
b0c39e
+      }
b0c39e
+
b0c39e
+      template<typename _Tp>
b0c39e
+      static bool
b0c39e
+      _M_not_empty_function(const _Tp*& __fp)
b0c39e
+      {
b0c39e
+        return __fp;
b0c39e
+      }
b0c39e
+
b0c39e
+      template<typename _Class, typename _Tp>
b0c39e
+      static bool
b0c39e
+      _M_not_empty_function(_Tp _Class::* const& __mp)
b0c39e
+      {
b0c39e
+        return __mp;
b0c39e
+      }
b0c39e
+
b0c39e
+      template<typename _Tp>
b0c39e
+      static bool
b0c39e
+      _M_not_empty_function(const _Tp&)
b0c39e
+      {
b0c39e
+        return true;
b0c39e
+      }
b0c39e
+
b0c39e
+    private:
b0c39e
+      static void
b0c39e
+      _M_init_functor(_Any_data& __functor, const _Functor& __f, true_type)
b0c39e
+      {
b0c39e
+        new (__functor._M_access()) _Functor(__f);
b0c39e
+      }
b0c39e
+
b0c39e
+      static void
b0c39e
+      _M_init_functor(_Any_data& __functor, const _Functor& __f, false_type)
b0c39e
+      {
b0c39e
+        __functor._M_access<_Functor*>() = new _Functor(__f);
b0c39e
+      }
b0c39e
+    };
b0c39e
+
b0c39e
+    template<typename _Functor>
b0c39e
+    class _Ref_manager : public _Base_manager<_Functor*>
b0c39e
+    {
b0c39e
+      typedef _Function_base::_Base_manager<_Functor*> _Base;
b0c39e
+
b0c39e
+    public:
b0c39e
+      static bool
b0c39e
+      _M_manager(_Any_data& __dest, const _Any_data& __source,
b0c39e
+                 _Manager_operation __op)
b0c39e
+      {
b0c39e
+        switch (__op) {
b0c39e
+        case __get_type_info:
b0c39e
+          __dest._M_access<const type_info*>() = &typeid(_Functor);
b0c39e
+          break;
b0c39e
+
b0c39e
+        case __get_functor_ptr:
b0c39e
+          __dest._M_access<_Functor*>() = *_Base::_M_get_pointer(__source);
b0c39e
+          return is_const<_Functor>::value;
b0c39e
+          break;
b0c39e
+
b0c39e
+        default:
b0c39e
+          _Base::_M_manager(__dest, __source, __op);
b0c39e
+        }
b0c39e
+        return false;
b0c39e
+      }
b0c39e
+
b0c39e
+      static void
b0c39e
+      _M_init_functor(_Any_data& __functor, reference_wrapper<_Functor> __f)
b0c39e
+      {
b0c39e
+        // TBD: Use address_of function instead
b0c39e
+        _Base::_M_init_functor(__functor, &__f.get());
b0c39e
+      }
b0c39e
+    };
b0c39e
+
b0c39e
+    _Function_base() : _M_manager(0) { }
b0c39e
+
b0c39e
+    ~_Function_base()
b0c39e
+    {
b0c39e
+      if (_M_manager)
b0c39e
+        {
b0c39e
+          _M_manager(_M_functor, _M_functor, __destroy_functor);
b0c39e
+        }
b0c39e
+    }
b0c39e
+
b0c39e
+
b0c39e
+    bool _M_empty() const { return !_M_manager; }
b0c39e
+
b0c39e
+    typedef bool (*_Manager_type)(_Any_data&, const _Any_data&,
b0c39e
+                                  _Manager_operation);
b0c39e
+
b0c39e
+    _Any_data     _M_functor;
b0c39e
+    _Manager_type _M_manager;
b0c39e
+  };
b0c39e
+
b0c39e
+  // [3.7.2.7] null pointer comparisons
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @brief Compares a polymorphic function object wrapper against 0
b0c39e
+   *  (the NULL pointer).
b0c39e
+   *  @returns @c true if the wrapper has no target, @c false otherwise
b0c39e
+   *
b0c39e
+   *  This function will not throw an exception.
b0c39e
+   */
b0c39e
+  template<typename _Signature>
b0c39e
+    inline bool
b0c39e
+    operator==(const function<_Signature>& __f, _M_clear_type*)
b0c39e
+    {
b0c39e
+      return !__f;
b0c39e
+    }
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @overload
b0c39e
+   */
b0c39e
+  template<typename _Signature>
b0c39e
+    inline bool
b0c39e
+    operator==(_M_clear_type*, const function<_Signature>& __f)
b0c39e
+    {
b0c39e
+      return !__f;
b0c39e
+    }
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @brief Compares a polymorphic function object wrapper against 0
b0c39e
+   *  (the NULL pointer).
b0c39e
+   *  @returns @c false if the wrapper has no target, @c true otherwise
b0c39e
+   *
b0c39e
+   *  This function will not throw an exception.
b0c39e
+   */
b0c39e
+  template<typename _Signature>
b0c39e
+    inline bool
b0c39e
+    operator!=(const function<_Signature>& __f, _M_clear_type*)
b0c39e
+    {
b0c39e
+      return __f;
b0c39e
+    }
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @overload
b0c39e
+   */
b0c39e
+  template<typename _Signature>
b0c39e
+    inline bool
b0c39e
+    operator!=(_M_clear_type*, const function<_Signature>& __f)
b0c39e
+    {
b0c39e
+      return __f;
b0c39e
+    }
b0c39e
+
b0c39e
+  // [3.7.2.8] specialized algorithms
b0c39e
+
b0c39e
+  /**
b0c39e
+   *  @brief Swap the targets of two polymorphic function object wrappers.
b0c39e
+   *
b0c39e
+   *  This function will not throw an exception.
b0c39e
+   */
b0c39e
+  template<typename _Signature>
b0c39e
+    inline void
b0c39e
+    swap(function<_Signature>& __x, function<_Signature>& __y)
b0c39e
+    {
b0c39e
+      __x.swap(__y);
b0c39e
+    }
b0c39e
+
b0c39e
+#define _GLIBCXX_JOIN(X,Y) _GLIBCXX_JOIN2( X , Y )
b0c39e
+#define _GLIBCXX_JOIN2(X,Y) _GLIBCXX_JOIN3(X,Y)
b0c39e
+#define _GLIBCXX_JOIN3(X,Y) X##Y
b0c39e
+#define _GLIBCXX_REPEAT_HEADER <tr1/functional_iterate.h>
b0c39e
+#include <tr1/repeat.h>
b0c39e
+#undef _GLIBCXX_REPEAT_HEADER
b0c39e
+#undef _GLIBCXX_JOIN3
b0c39e
+#undef _GLIBCXX_JOIN2
b0c39e
+#undef _GLIBCXX_JOIN
b0c39e
+
b0c39e
+  // Definition of default hash function std::tr1::hash<>.  The types for
b0c39e
+  // which std::tr1::hash<T> is defined is in clause 6.3.3. of the PDTR.
b0c39e
+  template<typename T>
b0c39e
+    struct hash;
b0c39e
+
b0c39e
+#define tr1_hashtable_define_trivial_hash(T)            \
b0c39e
+  template<>                                            \
b0c39e
+    struct hash<T>                                      \
b0c39e
+    : public std::unary_function<T, std::size_t>        \
b0c39e
+    {                                                   \
b0c39e
+      std::size_t                                       \
b0c39e
+      operator()(T val) const                           \
b0c39e
+      { return static_cast<std::size_t>(val); }         \
b0c39e
+    }                                                     
b0c39e
+
b0c39e
+  tr1_hashtable_define_trivial_hash(bool);
b0c39e
+  tr1_hashtable_define_trivial_hash(char);
b0c39e
+  tr1_hashtable_define_trivial_hash(signed char);
b0c39e
+  tr1_hashtable_define_trivial_hash(unsigned char);
b0c39e
+  tr1_hashtable_define_trivial_hash(wchar_t);
b0c39e
+  tr1_hashtable_define_trivial_hash(short);
b0c39e
+  tr1_hashtable_define_trivial_hash(int);
b0c39e
+  tr1_hashtable_define_trivial_hash(long);
b0c39e
+  tr1_hashtable_define_trivial_hash(unsigned short);
b0c39e
+  tr1_hashtable_define_trivial_hash(unsigned int);
b0c39e
+  tr1_hashtable_define_trivial_hash(unsigned long);
b0c39e
+  tr1_hashtable_define_trivial_hash(long long);
b0c39e
+  tr1_hashtable_define_trivial_hash(unsigned long long);
b0c39e
+
b0c39e
+#undef tr1_hashtable_define_trivial_hash
b0c39e
+
b0c39e
+  template<typename T>
b0c39e
+    struct hash<T*>
b0c39e
+    : public std::unary_function<T*, std::size_t>
b0c39e
+    {
b0c39e
+      std::size_t
b0c39e
+      operator()(T* p) const
b0c39e
+      { return reinterpret_cast<std::size_t>(p); }
b0c39e
+    };
b0c39e
+
b0c39e
+  // Fowler / Noll / Vo (FNV) Hash (type FNV-1a)
b0c39e
+  // (used by the next specializations of std::tr1::hash<>)
b0c39e
+
b0c39e
+  // Dummy generic implementation (for sizeof(size_t) != 4, 8).
b0c39e
+  template<std::size_t = sizeof(std::size_t)>
b0c39e
+    struct Fnv_hash
b0c39e
+    {
b0c39e
+      static std::size_t
b0c39e
+      hash(const char* first, std::size_t length)
b0c39e
+      {
b0c39e
+	std::size_t result = 0;
b0c39e
+	for (; length > 0; --length)
b0c39e
+	  result = (result * 131) + *first++;
b0c39e
+	return result;
b0c39e
+      }
b0c39e
+    };
b0c39e
+
b0c39e
+  template<>
b0c39e
+    struct Fnv_hash<4>
b0c39e
+    {
b0c39e
+      static std::size_t
b0c39e
+      hash(const char* first, std::size_t length)
b0c39e
+      {
b0c39e
+	std::size_t result = static_cast<std::size_t>(2166136261UL);
b0c39e
+	for (; length > 0; --length)
b0c39e
+	  {
b0c39e
+	    result ^= (std::size_t)*first++;
b0c39e
+	    result *= 16777619UL;
b0c39e
+	  }
b0c39e
+	return result;
b0c39e
+      }
b0c39e
+    };
b0c39e
+  
b0c39e
+  template<>
b0c39e
+    struct Fnv_hash<8>
b0c39e
+    {
b0c39e
+      static std::size_t
b0c39e
+      hash(const char* first, std::size_t length)
b0c39e
+      {
b0c39e
+	std::size_t result = static_cast<std::size_t>(14695981039346656037ULL);
b0c39e
+	for (; length > 0; --length)
b0c39e
+	  {
b0c39e
+	    result ^= (std::size_t)*first++;
b0c39e
+	    result *= 1099511628211ULL;
b0c39e
+	  }
b0c39e
+	return result;
b0c39e
+      }
b0c39e
+    };
b0c39e
+
b0c39e
+  // XXX String and floating point hashes probably shouldn't be inline
b0c39e
+  // member functions, since are nontrivial.  Once we have the framework
b0c39e
+  // for TR1 .cc files, these should go in one.
b0c39e
+  template<>
b0c39e
+    struct hash<std::string>
b0c39e
+    : public std::unary_function<std::string, std::size_t>
b0c39e
+    {      
b0c39e
+      std::size_t
b0c39e
+      operator()(const std::string& s) const
b0c39e
+      { return Fnv_hash<>::hash(s.data(), s.length()); }
b0c39e
+    };
b0c39e
+
b0c39e
+#ifdef _GLIBCXX_USE_WCHAR_T
b0c39e
+  template<>
b0c39e
+    struct hash<std::wstring>
b0c39e
+    : public std::unary_function<std::wstring, std::size_t>
b0c39e
+    {
b0c39e
+      std::size_t
b0c39e
+      operator()(const std::wstring& s) const
b0c39e
+      {
b0c39e
+	return Fnv_hash<>::hash(reinterpret_cast<const char*>(s.data()),
b0c39e
+				s.length() * sizeof(wchar_t));
b0c39e
+      }
b0c39e
+    };
b0c39e
+#endif
b0c39e
+
b0c39e
+  template<>
b0c39e
+    struct hash<float>
b0c39e
+    : public std::unary_function<float, std::size_t>
b0c39e
+    {
b0c39e
+      std::size_t
b0c39e
+      operator()(float fval) const
b0c39e
+      {
b0c39e
+	std::size_t result = 0;
b0c39e
+
b0c39e
+	// 0 and -0 both hash to zero.
b0c39e
+	if (fval != 0.0f)
b0c39e
+	  result = Fnv_hash<>::hash(reinterpret_cast<const char*>(&fval),
b0c39e
+				    sizeof(fval));
b0c39e
+	return result;
b0c39e
+      }
b0c39e
+    };
b0c39e
+
b0c39e
+  template<>
b0c39e
+    struct hash<double>
b0c39e
+    : public std::unary_function<double, std::size_t>
b0c39e
+    {
b0c39e
+      std::size_t
b0c39e
+      operator()(double dval) const
b0c39e
+      {
b0c39e
+	std::size_t result = 0;
b0c39e
+
b0c39e
+	// 0 and -0 both hash to zero.
b0c39e
+	if (dval != 0.0)
b0c39e
+	  result = Fnv_hash<>::hash(reinterpret_cast<const char*>(&dval),
b0c39e
+				    sizeof(dval));
b0c39e
+	return result;
b0c39e
+      }
b0c39e
+    };
b0c39e
+
b0c39e
+  // For long double, careful with random padding bits (e.g., on x86,
b0c39e
+  // 10 bytes -> 12 bytes) and resort to frexp.
b0c39e
+  template<>
b0c39e
+    struct hash<long double>
b0c39e
+    : public std::unary_function<long double, std::size_t>
b0c39e
+    {
b0c39e
+      std::size_t
b0c39e
+      operator()(long double ldval) const
b0c39e
+      {
b0c39e
+	std::size_t result = 0;
b0c39e
+
b0c39e
+	int exponent;
b0c39e
+	ldval = std::frexp(ldval, &exponent);
b0c39e
+	ldval = ldval < 0.0l ? -(ldval + 0.5l) : ldval;
b0c39e
+
b0c39e
+	const long double mult = std::numeric_limits<std::size_t>::max() + 1.0l;
b0c39e
+	ldval *= mult;
b0c39e
+
b0c39e
+	// Try to use all the bits of the mantissa (really necessary only
b0c39e
+	// on 32-bit targets, at least for 80-bit floating point formats).
b0c39e
+	const std::size_t hibits = (std::size_t)ldval;
b0c39e
+	ldval = (ldval - (long double)hibits) * mult;
b0c39e
+
b0c39e
+	const std::size_t coeff =
b0c39e
+	  (std::numeric_limits<std::size_t>::max()
b0c39e
+	   / std::numeric_limits<long double>::max_exponent);
b0c39e
+
b0c39e
+	result = hibits + (std::size_t)ldval + coeff * exponent;
b0c39e
+
b0c39e
+	return result;
b0c39e
+      }
b0c39e
+    };
b0c39e
+}
b0c39e
+}
b0c39e
+
b0c39e
+#endif