From 7831ecdb182b62d84d0c3c31868a29263d13752e Mon Sep 17 00:00:00 2001 From: Spp Date: Tue, 2 Oct 2012 15:06:19 +0200 Subject: Core: "Initial support for C++11 compilers" --- src/server/shared/Dynamic/HashNamespace.h | 119 ++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 src/server/shared/Dynamic/HashNamespace.h (limited to 'src/server/shared/Dynamic/HashNamespace.h') diff --git a/src/server/shared/Dynamic/HashNamespace.h b/src/server/shared/Dynamic/HashNamespace.h new file mode 100644 index 00000000000..c7b5a817b76 --- /dev/null +++ b/src/server/shared/Dynamic/HashNamespace.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2008-2012 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef TRINITY_HASH_NAMESPACE_H +#define TRINITY_HASH_NAMESPACE_H + +#include "Define.h" + +#if COMPILER_HAS_CPP11_SUPPORT +# define HASH_NAMESPACE_START namespace std { +# define HASH_NAMESPACE_END } +#elif defined(_STLPORT_VERSION) +# define HASH_NAMESPACE_START namespace std { +# define HASH_NAMESPACE_END } +#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1600 // VS100 +# define HASH_NAMESPACE_START namespace std { +# define HASH_NAMESPACE_END } +#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1500 && _HAS_TR1 +# define HASH_NAMESPACE_START namespace std { namespace tr1 { +# define HASH_NAMESPACE_END } } +#elif COMPILER == COMPILER_MICROSOFT && _MSC_VER >= 1300 +# define HASH_NAMESPACE_START namespace stdext { +# define HASH_NAMESPACE_END } + +#if !_HAS_TRADITIONAL_STL +#ifndef HASH_NAMESPACE +#define HASH_NAMESPACE +#else + +// can be not used by some platforms, so provide fake forward +HASH_NAMESPACE_START + +template +class hash +{ +public: + size_t operator() (K const&); +}; + +HASH_NAMESPACE_END + +#endif +#endif + +#elif COMPILER == COMPILER_INTEL +# define HASH_NAMESPACE_START namespace std { +# define HASH_NAMESPACE_END } +#elif COMPILER == COMPILER_GNU && defined(__clang__) && defined(_LIBCPP_VERSION) +# define HASH_NAMESPACE_START namespace std { +# define HASH_NAMESPACE_END } +#elif COMPILER == COMPILER_GNU && GCC_VERSION > 40200 +# define HASH_NAMESPACE_START namespace std { namespace tr1 { +# define HASH_NAMESPACE_END } } +#elif COMPILER == COMPILER_GNU && GCC_VERSION >= 30000 +# define HASH_NAMESPACE_START namespace __gnu_cxx { +# define HASH_NAMESPACE_END } + +#include +#include + +HASH_NAMESPACE_START + +template<> +class hash +{ +public: + size_t operator()(const unsigned long long &__x) const { return (size_t)__x; } +}; + +template +class hash +{ +public: + size_t operator()(T * const &__x) const { return (size_t)__x; } +}; + +template<> struct hash +{ + size_t operator()(const std::string &__x) const + { + return hash()(__x.c_str()); + } +}; + +HASH_NAMESPACE_END + +#else +# define HASH_NAMESPACE_START namespace std { +# define HASH_NAMESPACE_END } +#endif + +#if COMPILER != COMPILER_MICROSOFT + +// Visual Studio use non standard hash calculation function, so provide fake forward for other +HASH_NAMESPACE_START + +template +size_t hash_value(K const&); + +HASH_NAMESPACE_END + +#endif + +#endif -- cgit v1.2.3