OSDN Git Service

2010-11-10 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / stl_map.h
index 9614a12..8add2a4 100644 (file)
@@ -452,6 +452,21 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
        return (*__i).second;
       }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      mapped_type&
+      operator[](key_type&& __k)
+      {
+       // concept requirements
+       __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
+
+       iterator __i = lower_bound(__k);
+       // __i->first is greater than or equivalent to __k.
+       if (__i == end() || key_comp()(__k, (*__i).first))
+          __i = insert(__i, std::make_pair(std::move(__k), mapped_type()));
+       return (*__i).second;
+      }
+#endif
+
       // _GLIBCXX_RESOLVE_LIB_DEFECTS
       // DR 464. Suggestion for new member functions in standard containers.
       /**
@@ -501,6 +516,15 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
       { return _M_t._M_insert_unique(__x); }
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
+      template<typename _Pair, typename = typename
+              std::enable_if<std::is_convertible<_Pair,
+                                                 value_type>::value>::type>
+        std::pair<iterator, bool>
+        insert(_Pair&& __x)
+        { return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
+#endif
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
       /**
        *  @brief Attempts to insert a list of std::pairs into the %map.
        *  @param  list  A std::initializer_list<value_type> of pairs to be
@@ -544,6 +568,16 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
 #endif
       { return _M_t._M_insert_unique_(__position, __x); }
 
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+      template<typename _Pair, typename = typename
+              std::enable_if<std::is_convertible<_Pair,
+                                                 value_type>::value>::type>
+        iterator
+        insert(const_iterator __position, _Pair&& __x)
+        { return _M_t._M_insert_unique_(__position,
+                                       std::forward<_Pair>(__x)); }
+#endif
+
       /**
        *  @brief Template function that attempts to insert a range of elements.
        *  @param  first  Iterator pointing to the start of the range to be