1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // In most .h files, we would rather include a declaration of an stl 6 // rather than including the appropriate stl h file (which brings in 7 // lots of noise). For many STL classes this is ok (eg pair), but for 8 // some it's really annoying. We define those here, so you can 9 // just include this file instead of having to deal with the annoyance. 10 // 11 // Most of the annoyance, btw, has to do with the default allocator. 12 13 #ifndef _STL_DECL_MSVC_H 14 #define _STL_DECL_MSVC_H 15 16 // VC++ namespace / STL issues; make them explicit 17 #include <wchar.h> 18 #include <string> 19 #include <vector> 20 #include <functional> 21 #include <utility> 22 #include <set> 23 #include <list> 24 #define slist list 25 #include <algorithm> 26 #include <deque> 27 #include <iostream> 28 #include <map> 29 #include <queue> 30 #include <stack> 31 32 // copy_n isn't to be found anywhere in MSVC's STL 33 template <typename InputIterator, typename Size, typename OutputIterator> 34 std::pair<InputIterator, OutputIterator> 35 copy_n(InputIterator in, Size count, OutputIterator out) { 36 for ( ; count > 0; --count) { 37 *out = *in; 38 ++out; 39 ++in; 40 } 41 return std::make_pair(in, out); 42 } 43 44 // Nor are the following selectors 45 template <typename T> 46 struct identity { 47 inline const T& operator()(const T& t) const { return t; } 48 }; 49 50 // Copied from STLport 51 template <class _Pair> 52 struct select1st : public std::unary_function<_Pair, typename _Pair::first_type> { 53 const typename _Pair::first_type& operator()(const _Pair& __x) const { 54 return __x.first; 55 } 56 }; 57 58 template <class _Pair> 59 struct select2nd : public std::unary_function<_Pair, typename _Pair::second_type> 60 { 61 const typename _Pair::second_type& operator()(const _Pair& __x) const { 62 return __x.second; 63 } 64 }; 65 66 67 #if _MSC_VER >= 1300 68 69 // If you compile on Windows and get a compile-time error because 70 // some google3 code specifies a 3rd or 4th parameter to one of 71 // these template classes, then you have to put in some #ifdefs 72 // and use the NATIVE_HASH_NAMESPACE::hash_(set|map) implementation. 73 namespace msvchash { 74 template <typename Key> 75 struct hash; 76 77 template <class Key, 78 class HashFcn = hash<Key> > 79 class hash_set; 80 81 template <class Key, class Val, 82 class HashFcn = hash<Key> > 83 class hash_map; 84 85 template <class Key, 86 class HashFcn = hash<Key> > 87 class hash_multiset; 88 89 template <class Key, class Val, 90 class HashFcn = hash<Key> > 91 class hash_multimap; 92 } // end namespace msvchash 93 94 using msvchash::hash_set; 95 using msvchash::hash_map; 96 using msvchash::hash; 97 using msvchash::hash_multimap; 98 using msvchash::hash_multiset; 99 100 #else 101 #define hash_map map 102 #define hash_set set 103 #endif 104 105 using namespace std; 106 107 #endif /* #ifdef _STL_DECL_MSVC_H */ 108