Hideaki Tai / msgpack-embedded

Dependents:   hello_message_pack

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cpp_config.hpp Source File

cpp_config.hpp

00001 //
00002 // MessagePack for C++ C++03/C++11 Adaptation
00003 //
00004 // Copyright (C) 2013 KONDO Takatoshi
00005 //
00006 //    Distributed under the Boost Software License, Version 1.0.
00007 //    (See accompanying file LICENSE_1_0.txt or copy at
00008 //    http://www.boost.org/LICENSE_1_0.txt)
00009 //
00010 #ifndef MSGPACK_CPP_CONFIG_HPP
00011 #define MSGPACK_CPP_CONFIG_HPP
00012 
00013 #include "msgpack/versioning.hpp"
00014 
00015 #if !defined(MSGPACK_USE_CPP03)
00016 # if defined(_MSC_VER)
00017 #  if _MSC_VER < 1900
00018 #    define MSGPACK_USE_CPP03
00019 #  endif
00020 # elif (__cplusplus < 201103L)
00021 #  define MSGPACK_USE_CPP03
00022 # endif
00023 #endif // MSGPACK_USE_CPP03
00024 
00025 
00026 
00027 #if defined(MSGPACK_USE_CPP03)
00028 
00029 #if !defined(nullptr)
00030 #  if _MSC_VER < 1600
00031 #    define nullptr (0)
00032 #  endif
00033 #endif
00034 
00035 #include <memory>
00036 
00037 namespace msgpack {
00038 
00039 /// @cond
00040 MSGPACK_API_VERSION_NAMESPACE(v1) {
00041 /// @endcond
00042 
00043 template <typename T>
00044 struct unique_ptr : std::auto_ptr<T> {
00045     explicit unique_ptr(T* p = 0) throw() : std::auto_ptr<T>(p) {}
00046     unique_ptr(unique_ptr& a) throw() : std::auto_ptr<T>(a) {}
00047     template<class Y>
00048     unique_ptr (unique_ptr<Y>& a) throw() : std::auto_ptr<T>(a) {}
00049 };
00050 
00051 template <typename T>
00052 T& move(T& t)
00053 {
00054     return t;
00055 }
00056 
00057 template <typename T>
00058 T const& move(T const& t)
00059 {
00060     return t;
00061 }
00062 
00063 template <bool P, typename T = void>
00064 struct enable_if {
00065     typedef T type;
00066 };
00067 
00068 template <typename T>
00069 struct enable_if<false, T> {
00070 };
00071 
00072 template<typename T, T val>
00073 struct integral_constant {
00074     static T const value = val;
00075     typedef T value_type;
00076     typedef integral_constant<T, val> type;
00077 };
00078 
00079 typedef integral_constant<bool, true> true_type;
00080 typedef integral_constant<bool, false> false_type;
00081 
00082 template<class T, class U>
00083 struct is_same : false_type {};
00084 
00085 template<class T>
00086 struct is_same<T, T> : true_type {};
00087 
00088 /// @cond
00089 }  // MSGPACK_API_VERSION_NAMESPACE(v1)
00090 /// @endcond
00091 
00092 }  // namespace msgpack
00093 
00094 
00095 #else  // MSGPACK_USE_CPP03
00096 
00097 #include <memory>
00098 #include <tuple>
00099 
00100 namespace msgpack {
00101 /// @cond
00102 MSGPACK_API_VERSION_NAMESPACE(v1) {
00103 /// @endcond
00104 
00105     // unique_ptr
00106     using std::unique_ptr;
00107     // using std::make_unique; // since C++14
00108     using std::hash;
00109 
00110     // utility
00111     using std::move;
00112     using std::swap;
00113     using std::enable_if;
00114     using std::is_same;
00115 
00116 /// @cond
00117 }  // MSGPACK_API_VERSION_NAMESPACE(v1)
00118 /// @endcond
00119 }  // namespace msgpack
00120 
00121 
00122 #endif // MSGPACK_USE_CPP03
00123 
00124 #endif /* msgpack/cpp_config.hpp */