diff --git a/src/lol/algorithm/aabb_tree.h b/src/lol/algorithm/aabb_tree.h index fc6c385b..d5f774ca 100644 --- a/src/lol/algorithm/aabb_tree.h +++ b/src/lol/algorithm/aabb_tree.h @@ -377,7 +377,7 @@ protected: template class Quadtree : public AABBTree { - friend void Debug::Draw(Octree* tree, vec4 color); + friend void Debug::Draw(Octree* tree, vec4 color); public: Quadtree() { m_debug_y_offset = 0.f; } virtual ~Quadtree() { } @@ -390,7 +390,7 @@ protected: template class Octree : public AABBTree { - friend void Debug::Draw(Octree* tree, vec4 color); + friend void Debug::Draw(Octree* tree, vec4 color); public: Octree() { } virtual ~Octree() { } diff --git a/src/lol/algorithm/portal.h b/src/lol/algorithm/portal.h index c5937b40..6aa44005 100644 --- a/src/lol/algorithm/portal.h +++ b/src/lol/algorithm/portal.h @@ -13,12 +13,12 @@ #pragma once -#include /* for FLT_MAX */ - #include #include #include +#include /* for FLT_MAX */ + namespace lol { @@ -52,7 +52,7 @@ class PortalDoor { friend class PortalSet; friend class PortalRoom; - friend void Debug::Draw(PortalDoor& port, vec4 color); + friend void Debug::Draw(PortalDoor& port, vec4 color); private: void Init() diff --git a/src/lol/base/features.h b/src/lol/base/features.h index 6df19735..c50f8558 100644 --- a/src/lol/base/features.h +++ b/src/lol/base/features.h @@ -1,11 +1,13 @@ // -// Lol Engine +// Lol Engine // -// Copyright: (c) 2010-2014 Sam Hocevar -// This program is free software; you can redistribute it and/or -// modify it under the terms of the Do What The Fuck You Want To -// Public License, Version 2, as published by Sam Hocevar. See -// http://www.wtfpl.net/ for more details. +// Copyright © 2010—2015 Sam Hocevar +// +// This library is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. // #pragma once @@ -40,48 +42,65 @@ * Check for C++11 features. */ -/* Set these to 1 when Visual Studio finally understands the features - * (planned for Visual Studion 14) */ -#define LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS 0 -#define LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS 0 -#define LOL_FEATURE_CXX11_ARRAY_INITIALIZERS 0 -#define LOL_FEATURE_CXX11_CONSTEXPR 0 -#define LOL_FEATURE_CXX11_ISNAN 0 -#define LOL_FEATURE_CXX11_NULLPTR 0 - -/* This one is OK, except on GCC <= 4.6 */ -#define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 1 - -#if defined __GNUC__ /* GCC */ +/* These features aren't necessarily supported by all compilers */ +#undef LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS +#undef LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS +#undef LOL_FEATURE_CXX11_ARRAY_INITIALIZERS +#undef LOL_FEATURE_CXX11_CONSTEXPR +#undef LOL_FEATURE_CXX11_ISNAN /* FIXME: is this the right place? */ +#undef LOL_FEATURE_CXX11_NULLPTR +#undef LOL_FEATURE_CXX11_TEMPLATE_ALIASES +#undef LOL_FEATURE_CXX11_SFINAE_FOR_CTORS + +/* Features supported by GCC */ +#if defined __GNUC__ +# define LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS 1 +# define LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS 1 # if defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L -# undef LOL_FEATURE_CXX11_CONSTEXPR # define LOL_FEATURE_CXX11_CONSTEXPR 1 -# undef LOL_FEATURE_CXX11_ISNAN # define LOL_FEATURE_CXX11_ISNAN 1 -# undef LOL_FEATURE_CXX11_ARRAY_INITIALIZERS # define LOL_FEATURE_CXX11_ARRAY_INITIALIZERS 1 -# undef LOL_FEATURE_CXX11_NULLPTR # define LOL_FEATURE_CXX11_NULLPTR 1 +# define LOL_FEATURE_CXX11_SFINAE_FOR_CTORS 1 # endif -# if (__GNUC__ * 100 + __GNUC_MINOR__) < 470 -# undef LOL_FEATURE_CXX11_TEMPLATE_ALIASES -# define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 0 +# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 470 +# define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 1 # endif -#elif defined __has_feature /* Clang */ +#endif + +/* Features supported by Clang */ +#if !defined __GNUC__ && defined __has_feature +# define LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS 1 +# define LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS 1 +# define LOL_FEATURE_CXX11_ARRAY_INITIALIZERS 1 # if __has_feature(cxx_constexpr) -# undef LOL_FEATURE_CXX11_CONSTEXPR # define LOL_FEATURE_CXX11_CONSTEXPR 1 # endif +# define LOL_FEATURE_CXX11_ISNAN 1 # if __has_feature(cxx_nullptr) -# undef LOL_FEATURE_CXX11_NULLPTR # define LOL_FEATURE_CXX11_NULLPTR 1 # endif -# undef LOL_FEATURE_CXX11_ARRAY_INITIALIZERS -# define LOL_FEATURE_CXX11_ARRAY_INITIALIZERS 1 -#elif defined _MSC_VER /* Visual Studio (lol) */ -# if _MSC_VER < 1800 +# define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 1 +# define LOL_FEATURE_CXX11_SFINAE_FOR_CTORS 1 +#endif + +/* Features supported by Visual Studio */ +#if defined _MSC_VER +# define LOL_FEATURE_CXX11_TEMPLATE_ALIASES 1 +# define LOL_FEATURE_CXX11_ISNAN 1 +# if _MSC_VER >= 1900 /* 2015 CTP (not too bad) */ +# define LOL_FEATURE_CXX11_NULLPTR 1 +# define LOL_FEATURE_CXX11_SFINAE_FOR_CTORS 1 +# define LOL_FEATURE_CXX11_INHERIT_CONSTRUCTORS 1 +# endif +# if _MSC_VER < 1800 /* 2012 or older (ugly piece of shit) */ # error "sorry, Visual Studio 2013 or later is needed" # endif + /* Supported in VS 2015 but causes massive warning output */ +# undef LOL_FEATURE_CXX11_UNRESTRICTED_UNIONS + /* Still unsupported as of VS 2015 */ +# undef LOL_FEATURE_CXX11_ARRAY_INITIALIZERS +# undef LOL_FEATURE_CXX11_CONSTEXPR #endif diff --git a/src/lol/math/bigint.h b/src/lol/math/bigint.h index 8005a40a..95f61619 100644 --- a/src/lol/math/bigint.h +++ b/src/lol/math/bigint.h @@ -19,7 +19,8 @@ #include -#include +#include +#include namespace lol { diff --git a/src/lol/math/vector.h b/src/lol/math/vector.h index 8aa4ed0f..6d2c9552 100644 --- a/src/lol/math/vector.h +++ b/src/lol/math/vector.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright © 2010-2015 Sam Hocevar +// Copyright © 2010—2015 Sam Hocevar // // This library is free software. It comes without any warranty, to // the extent permitted by applicable law. You can redistribute it @@ -75,7 +75,7 @@ struct vec_t ~vec_t() = delete; /* Allow the assignment operator if unrestricted unions are supported. */ - inline vec_t& operator =(vec_t that); + inline vec_t& operator =(vec_t that) { for (int i = 0; i < N; ++i) (*this)[i] = that[i]; @@ -125,10 +125,17 @@ struct vec_t /* Explicit constructor that takes exactly N arguments thanks to SFINAE. */ template - explicit inline vec_t(typename std::enable_if<(sizeof...(ARGS) == N - 1) && (N > 1), T> - ::type const &X, ARGS... args) +#if LOL_FEATURE_CXX11_SFINAE_FOR_CTORS + explicit inline vec_t(T const &X, + typename std::enable_if::type const &Y, + ARGS... args) +#else + explicit inline vec_t(T const &X, T const &Y, ARGS... args) +#endif { - internal_init(m_data, X, args...); + static_assert(sizeof...(ARGS) + 2 == N, + "wrong argument count in vec_t constructor"); + internal_init(m_data, X, Y, args...); } /* Various explicit constructors */