Assume C++11 support

Remove all CMake checks for C++11 support since we now assume that we have it.
Replace all polyvox_* macros with standard C++ names.

See #48
This commit is contained in:
Matt Williams
2014-02-14 14:59:53 +00:00
parent 74be82e8cf
commit bc17c802bb
40 changed files with 36 additions and 604 deletions

View File

@ -26,6 +26,8 @@ distribution.
#include "PolyVoxCore/Impl/TypeDef.h"
#include <cstdint>
namespace PolyVox
{
/*

View File

@ -1,23 +0,0 @@
/*
* This file describes the capabilities of the C++ compiler and is used to determine which features to enable in PolyVox.
* It assumes that if the compiler is from VS2008 or earlier then no C++11 is present, otherwise it assumes full support
* is present.
*
* Not that this file is usually overwritten by CMake which does careful tests of the true compiler capabilities. However,
* we provide this default file so that CMake is not actually required for users of PolyVox and they can instead just drop
* PolyVox code into their project/makefile if they prefer.
*/
#ifndef __PolyVox_CompilerCapabilities_H__
#define __PolyVox_CompilerCapabilities_H__
// If we are not using Visual Studio (or we are but it
// is a recent version) then assume support for these.
#if !defined(_MSC_VER) || (_MSC_VER >= 1600)
#define HAS_CXX11_CONSTEXPR
#define HAS_CXX11_STATIC_ASSERT
#define HAS_CXX11_CSTDINT_H
#define HAS_CXX11_SHARED_PTR
#endif
#endif

View File

@ -1,17 +0,0 @@
/*
* This file is an input file for the CMake build system. It is processed and
* placed in the build directory by CMake.
*/
#ifndef __PolyVox_CompilerCapabilities_H__
#define __PolyVox_CompilerCapabilities_H__
#cmakedefine HAS_CXX11_CONSTEXPR
#cmakedefine HAS_CXX11_STATIC_ASSERT
#cmakedefine HAS_CXX11_CSTDINT_H
#cmakedefine HAS_CXX11_SHARED_PTR
#endif

View File

@ -110,35 +110,6 @@ freely, subject to the following restrictions:
#endif
/*
* Static Assertions
* -----------------
* These map to C+11 static_assert if available or our own implentation otherwise.
*/
#if defined(HAS_CXX11_STATIC_ASSERT)
//In this case we can just use static_assert
#define POLYVOX_STATIC_ASSERT static_assert
#else
namespace PolyVox
{
// empty default template
template <bool b>
struct StaticAssert {};
// template specialized on true
template <>
struct StaticAssert<true>
{
// If the static assertion is failing then this function won't exist. It will then
// appear in the error message which gives a clue to the user about what is wrong.
static void ERROR_The_static_assertion_has_failed() {}
};
}
#define POLYVOX_STATIC_ASSERT(condition, message) StaticAssert<(condition)>::ERROR_The_static_assertion_has_failed();
#endif
/*
* Exceptions
* ----------

View File

@ -26,6 +26,8 @@ freely, subject to the following restrictions:
#include "PolyVoxCore/Impl/TypeDef.h"
#include <cstdint>
namespace PolyVox
{
extern const POLYVOX_API uint16_t edgeTable[256];

View File

@ -24,8 +24,6 @@ freely, subject to the following restrictions:
#ifndef __PolyVox_TypeDef_H__
#define __PolyVox_TypeDef_H__
#include "PolyVoxCore/Impl/CompilerCapabilities.h"
//Definitions needed to make library functions accessable
// See http://gcc.gnu.org/wiki/Visibility for more info.
#if defined _WIN32 || defined __CYGWIN__
@ -69,52 +67,4 @@ freely, subject to the following restrictions:
#define POLYVOX_LOCAL
#endif // POLYVOX_SHARED
//Check which compiler we are using and work around unsupported features as necessary.
#if defined(_MSC_VER) && (_MSC_VER < 1600)
//To support old (pre-vc2010) Microsoft compilers we use boost to replace the
//std::shared_ptr and potentially other C++0x features. To use this capability you
//will need to make sure you have boost installed on your system.
#include <boost/function.hpp>
#define polyvox_function boost::function
#include <boost/bind.hpp>
#define polyvox_bind boost::bind
#define polyvox_placeholder_1 _1
#define polyvox_placeholder_2 _2
#else
//We have a decent compiler - use real C++0x features
#include <functional>
#define polyvox_function std::function
#define polyvox_bind std::bind
#define polyvox_placeholder_1 std::placeholders::_1
#define polyvox_placeholder_2 std::placeholders::_2
#endif
#if defined(HAS_CXX11_CONSTEXPR)
#define polyvox_constexpr_const constexpr //constexpr which falls back to const
#define polyvox_constexpr constexpr //constexpr which falls back to nothing
#else
#define polyvox_constexpr_const const
#define polyvox_constexpr
#endif
#if defined(HAS_CXX11_CSTDINT_H)
#include <cstdint>
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef long int32_t;
typedef unsigned long uint32_t;
#endif
#if defined(HAS_CXX11_SHARED_PTR)
#include <memory>
#define polyvox_shared_ptr std::shared_ptr
#else
#include <boost/smart_ptr.hpp>
#define polyvox_shared_ptr boost::shared_ptr
#endif
#endif