]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Make it compile again
authorMattia Basaglia <mattia.basaglia@gmail.com>
Sun, 26 Jul 2015 10:02:54 +0000 (12:02 +0200)
committerMattia Basaglia <mattia.basaglia@gmail.com>
Sun, 26 Jul 2015 10:02:54 +0000 (12:02 +0200)
CMakeLists.txt
libs/container/hashtable.cpp
libs/container/hashtable.h

index 23fabf545d46638641d5abc7fecb2d7c502d8fb0..cd42e5b4455404fdc428fc7f894c96dc12e4cb87 100644 (file)
@@ -3,6 +3,18 @@ cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
 project(NetRadiant C CXX)
 set(CMAKE_CXX_STANDARD 11)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
+# For some reason the above flags don't really work...
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
+    include(CheckCXXCompilerFlag)
+    check_cxx_compiler_flag(--std=c++${CMAKE_CXX_STANDARD} STD_CXX)
+    if(STD_CXX)
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++${CMAKE_CXX_STANDARD}")
+    else()
+        message(SEND_ERROR "Requires C++${CMAKE_CXX_STANDARD} or better")
+    endif()
+else()
+    message(WARNING "Unrecognized compiler: ${CMAKE_CXX_COMPILER_ID}, make sure it supports C++${CMAKE_CXX_STANDARD}")
+endif()
 
 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
 
@@ -524,10 +536,7 @@ add_library(stream
 add_library(string
     libs/string/pooledstring.cpp
     libs/string/pooledstring.h
-    libs/string/string.cpp
     libs/string/string.h
-    libs/string/stringfwd.cpp
-    libs/string/stringfwd.h
 )
 
 add_library(xml
index 046267accf4dd7a93a235ff3330bb6820f53ede9..372295bb8288b1dd9a36cfe4bdfc74016bf3c668 100644 (file)
@@ -32,11 +32,11 @@ void testStuff(){
        typedef HashTable<std::string, int, HashString> MyHashTable;
        MyHashTable hashtable;
        hashtable["bleh"] = 5;
-       hashtable.insert( "blah", 17 );
+       hashtable.insert({"blah", 17});
        hashtable["foo"] = 99;
-       hashtable.insert( "bar", 23 );
+       hashtable.insert({"bar", 23});
 
-       int bleh = ( *hashtable.find( "bleh" ) ).value; // 5
+       int bleh = ( *hashtable.find( "bleh" ) ).second; // 5
        int blah = hashtable["blah"]; // 17
        hashtable.erase( "foo" );
        MyHashTable::iterator barIter = hashtable.find( "bar" );
index 6b16bd60b8091092bf650ffabebea3aed1954a1d..cb27eace801a1523d4a85bd76ab019b3bea9b0db 100644 (file)
@@ -23,6 +23,7 @@
 #define INCLUDED_CONTAINER_HASHTABLE_H
 
 #include <unordered_map>
+#include "debugging/debugging.h"
 
 template<typename Key, typename Value, typename Hasher, typename KeyEqual = std::equal_to<Key> >
        using HashTable = std::unordered_map<Key, Value, Hasher, KeyEqual>;