| James E. King, III | 82ae957 | 2017-08-05 12:23:54 -0400 | [diff] [blame] | 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> |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 24 | #include <boost/version.hpp> |
| James E. King, III | 82ae957 | 2017-08-05 12:23:54 -0400 | [diff] [blame] | 25 | |
| 26 | /////////////////////////////////////////////////////////////////// |
| 27 | // |
| 28 | // functional (function, bind) |
| 29 | // |
| 30 | /////////////////////////////////////////////////////////////////// |
| 31 | |
| 32 | #if defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) || (defined(_MSC_VER) && _MSC_VER < 1800) || defined(FORCE_BOOST_FUNCTIONAL) |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 33 | #if (BOOST_VERSION <= 106500) |
| James E. King, III | 82ae957 | 2017-08-05 12:23:54 -0400 | [diff] [blame] | 34 | #include <boost/tr1/functional.hpp> |
| James E. King III | f5f430d | 2018-06-08 03:37:55 +0000 | [diff] [blame] | 35 | #else |
| 36 | #include <tr1/functional> |
| 37 | #endif |
| James E. King, III | 82ae957 | 2017-08-05 12:23:54 -0400 | [diff] [blame] | 38 | #define _THRIFT_FUNCTIONAL_TR1_ 1 |
| 39 | #endif |
| 40 | |
| 41 | #if _THRIFT_FUNCTIONAL_TR1_ |
| 42 | |
| 43 | namespace apache { namespace thrift { namespace stdcxx { |
| 44 | |
| 45 | using ::std::tr1::bind; |
| 46 | using ::std::tr1::function; |
| 47 | |
| 48 | namespace placeholders { |
| 49 | using ::std::tr1::placeholders::_1; |
| 50 | using ::std::tr1::placeholders::_2; |
| 51 | using ::std::tr1::placeholders::_3; |
| 52 | using ::std::tr1::placeholders::_4; |
| 53 | using ::std::tr1::placeholders::_5; |
| 54 | using ::std::tr1::placeholders::_6; |
| 55 | using ::std::tr1::placeholders::_7; |
| 56 | using ::std::tr1::placeholders::_8; |
| 57 | using ::std::tr1::placeholders::_9; |
| 58 | } // apache::thrift::stdcxx::placeholders |
| 59 | }}} // apache::thrift::stdcxx |
| 60 | |
| 61 | #else |
| 62 | |
| 63 | #include <functional> |
| 64 | |
| 65 | namespace apache { namespace thrift { namespace stdcxx { |
| 66 | using ::std::bind; |
| 67 | using ::std::function; |
| 68 | |
| 69 | namespace placeholders { |
| 70 | using ::std::placeholders::_1; |
| 71 | using ::std::placeholders::_2; |
| 72 | using ::std::placeholders::_3; |
| 73 | using ::std::placeholders::_4; |
| 74 | using ::std::placeholders::_5; |
| 75 | using ::std::placeholders::_6; |
| 76 | using ::std::placeholders::_7; |
| 77 | using ::std::placeholders::_8; |
| 78 | using ::std::placeholders::_9; |
| 79 | } // apache::thrift::stdcxx::placeholders |
| 80 | }}} // apache::thrift::stdcxx |
| 81 | |
| 82 | #endif |
| 83 | |
| 84 | /////////////////////////////////////////////////////////////////// |
| 85 | // |
| 86 | // Smart Pointers |
| 87 | // |
| 88 | /////////////////////////////////////////////////////////////////// |
| 89 | |
| 90 | // We can use std for memory functions only if the compiler supports template aliasing |
| 91 | // The macro BOOST_NO_CXX11_SMART_PTR is defined as 1 under Visual Studio 2010 and 2012 |
| 92 | // which do not support the feature, so we must continue to use C++98 and boost on them. |
| 93 | // We cannot use __cplusplus to detect this either, since Microsoft advertises an older one. |
| 94 | |
| 95 | #if defined(BOOST_NO_CXX11_SMART_PTR) || (defined(_MSC_VER) && _MSC_VER < 1800) || defined(FORCE_BOOST_SMART_PTR) |
| 96 | #include <boost/smart_ptr.hpp> |
| 97 | #else |
| 98 | #include <memory> |
| 99 | #endif |
| 100 | |
| 101 | namespace apache { namespace thrift { namespace stdcxx { |
| 102 | |
| 103 | #if defined(BOOST_NO_CXX11_SMART_PTR) || (defined(_MSC_VER) && _MSC_VER < 1800) || defined(FORCE_BOOST_SMART_PTR) |
| 104 | |
| 105 | using ::boost::const_pointer_cast; |
| 106 | using ::boost::dynamic_pointer_cast; |
| 107 | using ::boost::enable_shared_from_this; |
| 108 | using ::boost::make_shared; |
| 109 | using ::boost::scoped_ptr; |
| 110 | using ::boost::shared_ptr; |
| 111 | using ::boost::static_pointer_cast; |
| 112 | using ::boost::weak_ptr; |
| 113 | |
| 114 | #else |
| 115 | |
| 116 | using ::std::const_pointer_cast; |
| 117 | using ::std::dynamic_pointer_cast; |
| 118 | using ::std::enable_shared_from_this; |
| 119 | using ::std::make_shared; |
| 120 | template <typename T> using scoped_ptr = std::unique_ptr<T>; // compiler must support template aliasing |
| 121 | using ::std::shared_ptr; |
| 122 | using ::std::static_pointer_cast; |
| 123 | using ::std::weak_ptr; |
| 124 | |
| 125 | #endif |
| 126 | |
| 127 | }}} // apache::thrift::stdcxx |
| 128 | |
| 129 | #endif // #ifndef _THRIFT_STDCXX_H_ |