Compile with clang and add cotire

* Add cotire cmake module to speedup compilation https://github.com/sakra/cotire
* Fix clang error and warnings
* Rename Font to BitmapFont to fix conflict with Xlib.g Font typedef
* Remove legacy PCH support
* Improve Position hash
This commit is contained in:
Eduardo Bart
2012-06-16 20:19:43 -03:00
parent 4813b7eb4b
commit 10b33c6124
24 changed files with 2835 additions and 373 deletions

View File

@@ -23,6 +23,11 @@
#ifndef STDEXT_CAST_H
#define STDEXT_CAST_H
namespace stdext {
template<typename R, typename T> R safe_cast(const T& t);
template<typename R, typename T> R unsafe_cast(const T& t, R def = R());
}
#include "string.h"
#include "exception.h"
#include "demangle.h"
@@ -107,7 +112,7 @@ R safe_cast(const T& t) {
// cast a type to another type, cast errors are ignored
template<typename R, typename T>
R unsafe_cast(const T& t, R def = R()) {
R unsafe_cast(const T& t, R def) {
try {
return safe_cast<R,T>(t);
} catch(cast_exception& e) {

View File

@@ -23,12 +23,19 @@
#ifndef STDEXT_COMPILER_H
#define STDEXT_COMPILER_H
#if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#error "sorry, you need gcc 4.6 or greater to compile"
#ifdef __clang__
// clang is supported
#undef _GLIBCXX_USE_FLOAT128
#elif defined(__GNUC__)
#if !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#error "Sorry, you need gcc 4.6 or greater to compile."
#endif
#else
#error "Compiler not supported."
#endif
#if !defined(__GXX_EXPERIMENTAL_CXX0X__)
#error "sorry, you must enable C++0x to compile"
#error "Sorry, you must enable C++0x to compile."
#endif
// hack to enable std::thread on mingw32 4.6

View File

@@ -37,10 +37,6 @@
namespace stdext {
// casts declaration, definition will be included at the end of the file
template<typename R, typename T> R safe_cast(const T& t);
template<typename R, typename T> R unsafe_cast(const T& t, R def = R());
/// Convert any type to std::string
template<typename T>
std::string to_string(const T& t) { return unsafe_cast<std::string, T>(t); }