Sfoglia il codice sorgente

misc: various C++11-related compilation fixes for Visual Studio.

undefined
Sam Hocevar 9 anni fa
parent
commit
4196f315be
5 ha cambiato i file con 71 aggiunte e 44 eliminazioni
  1. +2
    -2
      src/lol/algorithm/aabb_tree.h
  2. +3
    -3
      src/lol/algorithm/portal.h
  3. +52
    -33
      src/lol/base/features.h
  4. +2
    -1
      src/lol/math/bigint.h
  5. +12
    -5
      src/lol/math/vector.h

+ 2
- 2
src/lol/algorithm/aabb_tree.h Vedi File

@@ -377,7 +377,7 @@ protected:
template <typename TE>
class Quadtree : public AABBTree<TE, vec2, box2, 4>
{
friend void Debug::Draw<TE>(Octree<TE>* tree, vec4 color);
friend void Debug::Draw<TE,void>(Octree<TE>* tree, vec4 color);
public:
Quadtree() { m_debug_y_offset = 0.f; }
virtual ~Quadtree() { }
@@ -390,7 +390,7 @@ protected:
template <typename TE>
class Octree : public AABBTree<TE, vec3, box3, 8>
{
friend void Debug::Draw<TE>(Octree<TE>* tree, vec4 color);
friend void Debug::Draw<TE,void>(Octree<TE>* tree, vec4 color);
public:
Octree() { }
virtual ~Octree() { }


+ 3
- 3
src/lol/algorithm/portal.h Vedi File

@@ -13,12 +13,12 @@

#pragma once

#include <cfloat> /* for FLT_MAX */

#include <lol/base/array.h>
#include <lol/debug/lines.h>
#include <lol/image/color.h>

#include <cfloat> /* for FLT_MAX */

namespace lol
{

@@ -52,7 +52,7 @@ class PortalDoor
{
friend class PortalSet<TE>;
friend class PortalRoom<TE>;
friend void Debug::Draw<TE>(PortalDoor<TE>& port, vec4 color);
friend void Debug::Draw<TE,void>(PortalDoor<TE>& port, vec4 color);

private:
void Init()


+ 52
- 33
src/lol/base/features.h Vedi File

@@ -1,11 +1,13 @@
//
// Lol Engine
// Lol Engine
//
// Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net>
// 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 <sam@hocevar.net>
//
// 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




+ 2
- 1
src/lol/math/bigint.h Vedi File

@@ -19,7 +19,8 @@

#include <lol/base/types.h>

#include <stdint.h>
#include <array>
#include <cstdint>

namespace lol
{


+ 12
- 5
src/lol/math/vector.h Vedi File

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net>
// Copyright © 20102015 Sam Hocevar <sam@hocevar.net>
//
// 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<T, N, SWIZZLE>& operator =(vec_t<T, N> that);
inline vec_t<T, N, SWIZZLE>& operator =(vec_t<T, N> that)
{
for (int i = 0; i < N; ++i)
(*this)[i] = that[i];
@@ -125,10 +125,17 @@ struct vec_t<T, N, FULL_SWIZZLE>

/* Explicit constructor that takes exactly N arguments thanks to SFINAE. */
template<typename... ARGS>
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<sizeof...(ARGS) + 2 == N, T>::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 */


Caricamento…
Annulla
Salva