mohaps / lrucache11

A header only C++11 LRU Cache template class that allows you to define key, value and optionally the Map type. uses a double linked list and a std::unordered_map style container to provide fast insert, delete and update No dependencies other than the C++ standard library. This is a C++11 remake of my earlier LRUCache project (https://github.com/mohaps/lrucache) The goal was to create a fast LRUCache header only library and to avoid any dependencies like boost.
https://github.com/mohaps/lrucache11
294 stars 63 forks source link

[BUG] fails to compile #6

Closed breznak closed 8 years ago

breznak commented 8 years ago

the error I'm getting,

In file included from SampleMain.cpp:1:
./LRUCache11.hpp:246:21: error: no type named 'lock_guard' in namespace 'std'
        using Guard = std::lock_guard<lock_type>;
                      ~~~~~^
./LRUCache11.hpp:246:31: error: expected ';' after alias declaration
        using Guard = std::lock_guard<lock_type>;
                                     ^
                                     ;
./LRUCache11.hpp:258:3: error: unknown type name 'Guard'
                Guard g(lock_);
                ^
./LRUCache11.hpp:262:3: error: unknown type name 'Guard'
                Guard g(lock_);
                ^

Thank you very much for looking into it!

mohaps commented 8 years ago

what is the cmd line you're using to compile? std::lock_guard is a c++11 feature. -std=c++11 is required for that

breznak commented 8 years ago

-std=c++11 is required for that

Yes, I do have that: $ clang++-3.7 -std=c++11 -o sample_main SampleMain.cpp && ./sample_main

The #3 fixes that for me.

mohaps commented 8 years ago

can you confirm with master if it still fails to compile?

breznak commented 8 years ago

@mohaps yes, the recent update & -lpthread as per readme fixes the compilation. Thank you! I'm closing this issue.