MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
hash_namespace.h
1/* Copyright 2013 10gen Inc.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#pragma once
17
18// We need to drag in a C++ header so we can examine __GXX_EXPERIMENTAL_CXX0X__ or
19// _LIBCPP_VERSION meaningfully. The <new> header is pretty lightweight, mostly unavoidable,
20// and almost certain to bring in the standard library configuration macros.
21#include <new>
22
23// NOTE(acm): Before gcc-4.7, __cplusplus is always defined to be 1, so we can't reliably
24// detect C++11 support by exclusively checking the value of __cplusplus. Additionaly, libc++,
25// whether in C++11 or C++03 mode, doesn't use TR1 and drops things into std instead.
26#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_LIBCPP_VERSION)
27
28#include <functional>
29
30#define MONGO_HASH_NAMESPACE_START namespace std {
31#define MONGO_HASH_NAMESPACE_END }
32#define MONGO_HASH_NAMESPACE std
33
34#elif defined(_MSC_VER) && _MSC_VER >= 1500
35
36#if _MSC_VER >= 1600 /* Visual Studio 2010+ */
37
38#include <functional>
39
40#define MONGO_HASH_NAMESPACE_START namespace std {
41#define MONGO_HASH_NAMESPACE_END }
42#define MONGO_HASH_NAMESPACE std
43
44#else /* Older Visual Studio */
45
46#include <tr1/functional>
47
48#define MONGO_HASH_NAMESPACE_START \
49 namespace std { \
50 namespace tr1 {
51#define MONGO_HASH_NAMESPACE_END \
52 } \
53 }
54#define MONGO_HASH_NAMESPACE std::tr1
55
56#endif
57
58#elif defined(__GNUC__)
59
60#include <tr1/functional>
61
62#define MONGO_HASH_NAMESPACE_START \
63 namespace std { \
64 namespace tr1 {
65#define MONGO_HASH_NAMESPACE_END \
66 } \
67 }
68#define MONGO_HASH_NAMESPACE std::tr1
69
70#else
71#error "Cannot determine namespace for 'hash'"
72#endif