1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef _THRIFT_STDCXX_H_
21#define _THRIFT_STDCXX_H_ 1
22
23#include <boost/config.hpp>
24
25///////////////////////////////////////////////////////////////////
26//
27// functional (function, bind)
28//
29///////////////////////////////////////////////////////////////////
30
31#if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) || (defined(_MSC_VER) && _MSC_VER < 1800) || defined(FORCE_BOOST_FUNCTIONAL)
32#include <boost/tr1/functional.hpp>
33#define _THRIFT_FUNCTIONAL_TR1_ 1
34#endif
35
36#if _THRIFT_FUNCTIONAL_TR1_
37
38 namespace apache { namespace thrift { namespace stdcxx {
39
40 using ::std::tr1::bind;
41 using ::std::tr1::function;
42
43 namespace placeholders {
44 using ::std::tr1::placeholders::_1;
45 using ::std::tr1::placeholders::_2;
46 using ::std::tr1::placeholders::_3;
47 using ::std::tr1::placeholders::_4;
48 using ::std::tr1::placeholders::_5;
49 using ::std::tr1::placeholders::_6;
50 using ::std::tr1::placeholders::_7;
51 using ::std::tr1::placeholders::_8;
52 using ::std::tr1::placeholders::_9;
53 } // apache::thrift::stdcxx::placeholders
54 }}} // apache::thrift::stdcxx
55
56#else
57
58 #include <functional>
59
60 namespace apache { namespace thrift { namespace stdcxx {
61 using ::std::bind;
62 using ::std::function;
63
64 namespace placeholders {
65 using ::std::placeholders::_1;
66 using ::std::placeholders::_2;
67 using ::std::placeholders::_3;
68 using ::std::placeholders::_4;
69 using ::std::placeholders::_5;
70 using ::std::placeholders::_6;
71 using ::std::placeholders::_7;
72 using ::std::placeholders::_8;
73 using ::std::placeholders::_9;
74 } // apache::thrift::stdcxx::placeholders
75 }}} // apache::thrift::stdcxx
76
77#endif
78
79///////////////////////////////////////////////////////////////////
80//
81// Smart Pointers
82//
83///////////////////////////////////////////////////////////////////
84
85// We can use std for memory functions only if the compiler supports template aliasing
86// The macro BOOST_NO_CXX11_SMART_PTR is defined as 1 under Visual Studio 2010 and 2012
87// which do not support the feature, so we must continue to use C++98 and boost on them.
88// We cannot use __cplusplus to detect this either, since Microsoft advertises an older one.
89
90#if defined(BOOST_NO_CXX11_SMART_PTR) || (defined(_MSC_VER) && _MSC_VER < 1800) || defined(FORCE_BOOST_SMART_PTR)
91#include <boost/smart_ptr.hpp>
92#else
93#include <memory>
94#endif
95
96namespace apache { namespace thrift { namespace stdcxx {
97
98#if defined(BOOST_NO_CXX11_SMART_PTR) || (defined(_MSC_VER) && _MSC_VER < 1800) || defined(FORCE_BOOST_SMART_PTR)
99
100 using ::boost::const_pointer_cast;
101 using ::boost::dynamic_pointer_cast;
102 using ::boost::enable_shared_from_this;
103 using ::boost::make_shared;
104 using ::boost::scoped_ptr;
105 using ::boost::shared_ptr;
106 using ::boost::static_pointer_cast;
107 using ::boost::weak_ptr;
108
109#else
110
111 using ::std::const_pointer_cast;
112 using ::std::dynamic_pointer_cast;
113 using ::std::enable_shared_from_this;
114 using ::std::make_shared;
115 template <typename T> using scoped_ptr = std::unique_ptr<T>; // compiler must support template aliasing
116 using ::std::shared_ptr;
117 using ::std::static_pointer_cast;
118 using ::std::weak_ptr;
119
120#endif
121
122}}} // apache::thrift::stdcxx
123
124#endif // #ifndef _THRIFT_STDCXX_H_
125