Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / cld / base / stl_decl_msvc.h
blob130b8e121dcde724f16cf6ea3cfde2b3484ebf40
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.
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.
11 // Most of the annoyance, btw, has to do with the default allocator.
13 #ifndef _STL_DECL_MSVC_H
14 #define _STL_DECL_MSVC_H
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>
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;
41 return std::make_pair(in, out);
44 // Nor are the following selectors
45 template <typename T>
46 struct identity {
47 inline const T& operator()(const T& t) const { return t; }
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;
58 template <class _Pair>
59 struct select2nd : public std::unary_function<_Pair, typename _Pair::second_type>
61 const typename _Pair::second_type& operator()(const _Pair& __x) const {
62 return __x.second;
67 #if _MSC_VER >= 1300
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;
77 template <class Key,
78 class HashFcn = hash<Key> >
79 class hash_set;
81 template <class Key, class Val,
82 class HashFcn = hash<Key> >
83 class hash_map;
85 template <class Key,
86 class HashFcn = hash<Key> >
87 class hash_multiset;
89 template <class Key, class Val,
90 class HashFcn = hash<Key> >
91 class hash_multimap;
92 } // end namespace msvchash
94 using msvchash::hash_set;
95 using msvchash::hash_map;
96 using msvchash::hash;
97 using msvchash::hash_multimap;
98 using msvchash::hash_multiset;
100 #else
101 #define hash_map map
102 #define hash_set set
103 #endif
105 using namespace std;
107 #endif /* #ifdef _STL_DECL_MSVC_H */