OSDN Git Service

2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / profile / bitset
index 96a59ea..a995afa 100644 (file)
@@ -1,6 +1,6 @@
 // Profiling bitset implementation -*- C++ -*-
 
-// Copyright (C) 2009 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010 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
 
 #include <bitset>
 
-namespace std
+namespace std _GLIBCXX_VISIBILITY(default)
 {
 namespace __profile
 {
-  /** @brief Bitset wrapper with performance instrumentation.  */
+  /// Class std::bitset wrapper with performance instrumentation.
   template<size_t _Nb>
     class bitset
-    : public _GLIBCXX_STD_D::bitset<_Nb>
+    : public _GLIBCXX_STD_C::bitset<_Nb>
     {
-      typedef _GLIBCXX_STD_D::bitset<_Nb> _Base;
+      typedef _GLIBCXX_STD_C::bitset<_Nb> _Base;
 
     public:
       // bit reference:
@@ -95,9 +95,14 @@ namespace __profile
       };
 
       // 23.3.5.1 constructors:
-      bitset() : _Base() { }
+      _GLIBCXX_CONSTEXPR bitset() : _Base() { }
 
-      bitset(unsigned long __val) : _Base(__val) { }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      constexpr bitset(unsigned long long __val)
+#else
+      bitset(unsigned long __val)
+#endif
+      : _Base(__val) { }
 
       template<typename _CharT, typename _Traits, typename _Alloc>
         explicit
@@ -121,6 +126,16 @@ namespace __profile
 
       bitset(const _Base& __x) : _Base(__x) { }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      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(__str, __n, __zero, __one) { }
+#endif
+
       // 23.3.5.2 bitset operations:
       bitset<_Nb>&
       operator&=(const bitset<_Nb>& __rhs)
@@ -221,6 +236,9 @@ namespace __profile
       }
 
       using _Base::to_ulong;
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      using _Base::to_ullong;
+#endif
 
       template <typename _CharT, typename _Traits, typename _Alloc>
         std::basic_string<_CharT, _Traits, _Alloc>
@@ -340,6 +358,20 @@ namespace __profile
               const bitset<_Nb>& __x)
     { return __os << __x._M_base(); }
 } // namespace __profile
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+  // DR 1182.
+  /// std::hash specialization for bitset.
+  template<size_t _Nb>
+    struct hash<__profile::bitset<_Nb>>
+    : public __hash_base<size_t, __profile::bitset<_Nb>>
+    {
+      size_t
+      operator()(const __profile::bitset<_Nb>& __b) const
+      { return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); }
+    };
+#endif
+
 } // namespace std
 
 #endif