diff --git a/jubatus/util/data/serialization/tr1_unordered_map.h b/jubatus/util/data/serialization/tr1_unordered_map.h index 016a8848..1b2dc198 100644 --- a/jubatus/util/data/serialization/tr1_unordered_map.h +++ b/jubatus/util/data/serialization/tr1_unordered_map.h @@ -32,12 +32,12 @@ #ifndef JUBATUS_UTIL_DATA_SERIALIZATION_TR1_UNORDERED_MAP_H_ #define JUBATUS_UTIL_DATA_SERIALIZATION_TR1_UNORDERED_MAP_H_ +#if defined(__GLIBCXX__) && __cplusplus < 201103 + #include "base.h" #include // Include a lightweight header for __GLIBCXX__. -#ifdef __GLIBCXX__ #include -#endif #include "pair.h" @@ -46,8 +46,6 @@ namespace util{ namespace data{ namespace serialization{ -#ifdef __GLIBCXX__ - template void serialize(Archive &ar, std::tr1::unordered_map &m) { @@ -71,10 +69,10 @@ void serialize(Archive &ar, std::tr1::unordered_map &m) } } -#endif - } // serialization } // data } // util } // jubatus + +#endif // #if defined(__GLIBCXX__) && __cplusplus < 201103 #endif // #ifndef JUBATUS_UTIL_DATA_SERIALIZATION_TR1_UNORDERED_MAP_H_ diff --git a/jubatus/util/data/serialization/tr1_unordered_set.h b/jubatus/util/data/serialization/tr1_unordered_set.h index 5bee6fde..92806b98 100644 --- a/jubatus/util/data/serialization/tr1_unordered_set.h +++ b/jubatus/util/data/serialization/tr1_unordered_set.h @@ -32,12 +32,12 @@ #ifndef JUBATUS_UTIL_DATA_SERIALIZATION_TR1_UNORDERED_SET_H_ #define JUBATUS_UTIL_DATA_SERIALIZATION_TR1_UNORDERED_SET_H_ +#if defined(__GLIBCXX__) && __cplusplus < 201103 + #include "base.h" #include // include a lightweight header for __GLIBCXX__. -#ifdef __GLIBCXX__ #include -#endif #include "pair.h" @@ -46,8 +46,6 @@ namespace util{ namespace data{ namespace serialization{ -#ifdef __GLIBCXX__ - template void serialize(Archive &ar, std::tr1::unordered_set &s) { @@ -71,10 +69,10 @@ void serialize(Archive &ar, std::tr1::unordered_set &s) } } -#endif - } // serialization } // data } // util } // jubatus + +#endif // #if defined(__GLIBCXX__) && __cplusplus < 201103 #endif // #ifndef JUBATUS_UTIL_DATA_SERIALIZATION_TR1_UNORDERED_SET_H_ diff --git a/jubatus/util/data/serialization_test.cpp b/jubatus/util/data/serialization_test.cpp index b2c9c61a..6f559e71 100644 --- a/jubatus/util/data/serialization_test.cpp +++ b/jubatus/util/data/serialization_test.cpp @@ -40,11 +40,11 @@ #include "jubatus/util/util-config.h" -#if HAVE_TR1_UNORDERED_MAP +#if !HAVE_UNORDERED_MAP && HAVE_TR1_UNORDERED_MAP #include "./serialization/tr1_unordered_map.h" #endif -#if HAVE_TR1_UNORDERED_SET +#if !HAVE_UNORDERED_SET && HAVE_TR1_UNORDERED_SET #include "./serialization/tr1_unordered_set.h" #endif @@ -302,7 +302,7 @@ TEST(serialization, string) { for (string::iterator it=vs1.begin(),jt=vs2.begin();it!=vs1.end();++it,++jt) EXPECT_EQ(*it,*jt); } -#if HAVE_TR1_UNORDERED_MAP +#if !HAVE_UNORDERED_MAP && HAVE_TR1_UNORDERED_MAP TEST(serialization, tr1_unordered_map) { srandom(time(NULL)); @@ -348,7 +348,7 @@ TEST(serialization, pficommon_unordered_map){ } } -#if HAVE_TR1_UNORDERED_SET +#if !HAVE_UNORDERED_SET && HAVE_TR1_UNORDERED_SET TEST(serialization, tr1_unordered_set) { srandom(time(NULL)); diff --git a/jubatus/util/lang/enable_shared_from_this.h b/jubatus/util/lang/enable_shared_from_this.h index 09c38b5d..c7f15e1c 100644 --- a/jubatus/util/lang/enable_shared_from_this.h +++ b/jubatus/util/lang/enable_shared_from_this.h @@ -33,7 +33,7 @@ #define JUBATUS_UTIL_LANG_ENABLE_SHARED_FROM_THIS_H_ #include -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 #include #endif #include "shared_ptr.h" @@ -43,7 +43,7 @@ namespace util { namespace lang { namespace detail { -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 namespace enable_shared_from_this_ns = ::std::tr1; #else namespace enable_shared_from_this_ns = ::std; diff --git a/jubatus/util/lang/function.h b/jubatus/util/lang/function.h index e0b59a02..f3c66d60 100644 --- a/jubatus/util/lang/function.h +++ b/jubatus/util/lang/function.h @@ -33,7 +33,7 @@ #define JUBATUS_UTIL_LANG_FUNCTION_H_ #include -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 #include #endif @@ -42,7 +42,7 @@ namespace util { namespace lang { namespace detail { -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 namespace function_ns = ::std::tr1; #else namespace function_ns = ::std; diff --git a/jubatus/util/lang/ref.h b/jubatus/util/lang/ref.h index a98a75a3..5023a0ef 100644 --- a/jubatus/util/lang/ref.h +++ b/jubatus/util/lang/ref.h @@ -33,7 +33,7 @@ #define JUBATUS_UTIL_LANG_REF_H_ #include -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 #include #endif @@ -42,7 +42,7 @@ namespace util { namespace lang { namespace detail { -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 namespace ref_ns = ::std::tr1; #else namespace ref_ns = ::std; diff --git a/jubatus/util/lang/shared_ptr.h b/jubatus/util/lang/shared_ptr.h index f4231180..8f625ef6 100644 --- a/jubatus/util/lang/shared_ptr.h +++ b/jubatus/util/lang/shared_ptr.h @@ -34,7 +34,7 @@ #include #include -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 #include #endif @@ -64,7 +64,7 @@ template class enable_shared_from_this; namespace detail { -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 namespace shared_ptr_ns = ::std::tr1; #else namespace shared_ptr_ns = ::std; diff --git a/jubatus/util/lang/weak_ptr.h b/jubatus/util/lang/weak_ptr.h index a4694a71..a6d464ac 100644 --- a/jubatus/util/lang/weak_ptr.h +++ b/jubatus/util/lang/weak_ptr.h @@ -33,7 +33,7 @@ #define JUBATUS_UTIL_LANG_WEAK_PTR_H_ #include -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 #include #endif @@ -42,7 +42,7 @@ namespace util { namespace lang { namespace detail { -#ifdef __GLIBCXX__ +#if defined(__GLIBCXX__) && __cplusplus < 201103 namespace weak_ptr_ns = ::std::tr1; #else namespace weak_ptr_ns = ::std; diff --git a/wscript b/wscript index 3118da81..ee884a93 100644 --- a/wscript +++ b/wscript @@ -62,6 +62,18 @@ def configure(conf): conf.check_cxx(lib = 'msgpack') + if conf.check_cxx(cxxflags='-std=c++11', mandatory=False, uselib_store='cpp11'): + # __GLIBCXX__: + # Ubuntu 14.04: 20150426 + # CentOS 7: 20150623 + libstdcpp_test = ( + '#include \n' + '#if defined(__GLIBCXX__) && __GLIBCXX__ < 20150426\n' + '#error\n#endif\nint main(){}') + if conf.check_cxx(fragment=libstdcpp_test, mandatory=False, + msg='Checkint libstdc++ version', uselib='cpp11'): + env.append_unique('CXXFLAGS', ['-std=c++11', '-Wno-deprecated-declarations']) + if Options.options.debug: conf.define('_GLIBCXX_DEBUG', 1) else: