Repassage à C++11 pour compatibilité

This commit is contained in:
Mattéo Delabre 2016-03-31 10:20:09 +02:00
parent bc858a05d2
commit 81434c9b7a
6 changed files with 15 additions and 14 deletions

14
CMakeLists.txt vendored
View File

@ -18,15 +18,15 @@ endif()
# Standard C++14 # Standard C++14
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX14) if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX1Y) elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else() else()
message(STATUS "Le compilateur actuel (${CMAKE_CXX_COMPILER}) ne supporte pas C++14. Merci d'utiliser un autre compilateur.") message(STATUS "Le compilateur actuel (${CMAKE_CXX_COMPILER}) ne supporte pas C++11. Merci d'utiliser un autre compilateur.")
endif() endif()
# Recherche des librairies # Recherche des librairies

View File

@ -36,11 +36,11 @@ void Block::draw(Manager& manager) {
} }
std::unique_ptr<sf::FloatRect> Block::getAABB() const { std::unique_ptr<sf::FloatRect> Block::getAABB() const {
return std::make_unique<sf::FloatRect>( return std::unique_ptr<sf::FloatRect>(new sf::FloatRect(
getPosition().x - Constants::GRID / 2, getPosition().x - Constants::GRID / 2,
getPosition().y - Constants::GRID / 2, getPosition().y - Constants::GRID / 2,
Constants::GRID, Constants::GRID Constants::GRID, Constants::GRID
); ));
} }
const unsigned int Block::TYPE_ID = 1; const unsigned int Block::TYPE_ID = 1;

View File

@ -53,7 +53,8 @@ void Game::load(std::ifstream& file) {
pos_x *= Constants::GRID; pos_x *= Constants::GRID;
pos_y *= Constants::GRID; pos_y *= Constants::GRID;
std::shared_ptr<Player> player = std::make_shared<Player>(pos_x, pos_y); std::shared_ptr<Player> player =
std::shared_ptr<Player>(new Player(pos_x, pos_y));
player->setPlayerNumber(i); player->setPlayerNumber(i);
objects.push_back(std::dynamic_pointer_cast<Object>(player)); objects.push_back(std::dynamic_pointer_cast<Object>(player));

View File

@ -10,7 +10,7 @@
int main() { int main() {
Manager manager; Manager manager;
std::shared_ptr<Game> game = std::make_shared<Game>(manager); std::shared_ptr<Game> game = std::shared_ptr<Game>(new Game(manager));
// ouverture du niveau // ouverture du niveau
std::ifstream file; std::ifstream file;

View File

@ -53,11 +53,11 @@ void Player::draw(Manager& manager) {
} }
std::unique_ptr<sf::FloatRect> Player::getAABB() const { std::unique_ptr<sf::FloatRect> Player::getAABB() const {
return std::make_unique<sf::FloatRect>( return std::unique_ptr<sf::FloatRect>(new sf::FloatRect(
getPosition().x - getRadius(), getPosition().x - getRadius(),
getPosition().y - getRadius(), getPosition().y - getRadius(),
2 * getRadius(), 2 * getRadius() 2 * getRadius(), 2 * getRadius()
); ));
} }
const unsigned int Player::TYPE_ID = 0; const unsigned int Player::TYPE_ID = 0;

View File

@ -16,7 +16,7 @@ ResourceManager::~ResourceManager() {
*/ */
std::string getCurrentDirectory() { std::string getCurrentDirectory() {
int length = wai_getExecutablePath(NULL, 0, NULL), dirname_length; int length = wai_getExecutablePath(NULL, 0, NULL), dirname_length;
std::unique_ptr<char[]> buffer = std::make_unique<char[]>(length + 1); std::unique_ptr<char[]> buffer = std::unique_ptr<char[]>(new char[length + 1]);
wai_getExecutablePath(buffer.get(), length, &dirname_length); wai_getExecutablePath(buffer.get(), length, &dirname_length);
if (dirname_length == 0) { if (dirname_length == 0) {