aboutsummaryrefslogtreecommitdiff
path: root/src/common/Common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/Common.h')
-rw-r--r--src/common/Common.h74
1 files changed, 16 insertions, 58 deletions
diff --git a/src/common/Common.h b/src/common/Common.h
index 1097249bcab..78b7df6a895 100644
--- a/src/common/Common.h
+++ b/src/common/Common.h
@@ -20,38 +20,9 @@
#define TRINITYCORE_COMMON_H
#include "Define.h"
-
-#include <algorithm>
-#include <array>
-#include <exception>
-#include <list>
-#include <map>
#include <memory>
-#include <queue>
-#include <set>
-#include <sstream>
#include <string>
-#include <type_traits>
-#include <unordered_map>
-#include <unordered_set>
-#include <vector>
-#include <numeric>
-
-#include <cmath>
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-#include <ctime>
-#include <cerrno>
-#include <csignal>
-
-#include <boost/optional.hpp>
-#include <boost/utility/in_place_factory.hpp>
-#include <boost/functional/hash.hpp>
-
-#include "Debugging/Errors.h"
-
-#include "Threading/LockedQueue.h"
+#include <utility>
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
# include <ws2tcpip.h>
@@ -61,7 +32,6 @@
# define BOOST_ASIO_HAS_MOVE
# endif // !defined(BOOST_ASIO_HAS_MOVE)
# endif // if TRINITY_COMPILER == TRINITY_COMPILER_INTEL
-
#else
# include <sys/types.h>
# include <sys/ioctl.h>
@@ -69,12 +39,11 @@
# include <netinet/in.h>
# include <unistd.h>
# include <netdb.h>
+# include <cstdlib>
#endif
#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
-#include <float.h>
-
#define snprintf _snprintf
#define atoll _atoi64
#define vsnprintf _vsnprintf
@@ -87,8 +56,6 @@
#endif
-inline float finiteAlways(float f) { return std::isfinite(f) ? f : 0.0f; }
-
inline unsigned long atoul(char const* str) { return strtoul(str, nullptr, 10); }
inline unsigned long long atoull(char const* str) { return strtoull(str, nullptr, 10); }
@@ -114,7 +81,7 @@ enum AccountTypes
SEC_CONSOLE = 4 // must be always last in list, accounts must have less security level always also
};
-enum LocaleConstant
+enum LocaleConstant : uint8
{
LOCALE_enUS = 0,
LOCALE_koKR = 1,
@@ -136,11 +103,9 @@ enum LocaleConstant
TC_COMMON_API extern char const* localeNames[TOTAL_LOCALES];
-TC_COMMON_API LocaleConstant GetLocaleByName(const std::string& name);
-
-typedef std::vector<std::string> StringVector;
+TC_COMMON_API LocaleConstant GetLocaleByName(std::string const& name);
-// we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some other platforms)
+// we always use stdlib std::max/std::min, undefine some not C++ standard defines (Win API and some other platforms)
#ifdef max
#undef max
#endif
@@ -155,33 +120,26 @@ typedef std::vector<std::string> StringVector;
#define MAX_QUERY_LEN 32*1024
-//! Optional helper class to wrap optional values within.
-template <typename T>
-using Optional = boost::optional<T>;
-
namespace Trinity
{
//! std::make_unique implementation (TODO: remove this once C++14 is supported)
template<typename T, typename ...Args>
- std::unique_ptr<T> make_unique(Args&& ...args)
+ inline auto make_unique(Args&& ...args) ->
+ typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
-}
-//! Hash implementation for std::pair to allow using pairs in unordered_set or as key for unordered_map
-//! Individual types used in pair must be hashable by boost::hash
-namespace std
-{
- template<class K, class V>
- struct hash<std::pair<K, V>>
+ template<typename T>
+ inline auto make_unique(std::size_t size) ->
+ typename std::enable_if<std::is_array<T>::value && std::extent<T>::value == 0, std::unique_ptr<T>>::type
{
- public:
- size_t operator()(std::pair<K, V> const& key) const
- {
- return boost::hash_value(key);
- }
- };
+ return std::unique_ptr<T>(new typename std::remove_extent<T>::type[size]());
+ }
+
+ template<typename T, typename... Args>
+ inline auto make_unique(Args&&...) ->
+ typename std::enable_if<std::extent<T>::value != 0, void>::type = delete;
}
#endif