2014-01-13 52 views
1

時,當我在課堂上使用一個std ::雙端隊列爲私有成員,我得到很多的錯誤,像錯誤使用std :: deque的<std::string>

/usr/include/c++/v1/deque:907:49: error: implicit instantiation of undefined template 'std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >' static const difference_type __block_size = sizeof(value_type) < 256 ? 4096/sizeof(value_type) : 16;

/usr/include/c++/v1/deque:1181:30: error: '__alloc_traits' is a protected member of 'std::__1::__deque_base<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >' typedef typename __base::__alloc_traits __alloc_traits;

等上。

它適用於我使用矢量,但我想要一個pop_front功能。

任何想法?

編輯:
代碼:

#include <deque> 
class Example { 
    public: 
     Example() {} 
     ~Example() {} 
    private: 
     std::deque<std::string> m_deque; 
}; 

回答

5

你必須包括#include <string>

+0

我看到現在,但爲什麼它的std ::向量的工作呢? – gartenriese

+0

@gartenriese因爲'vector'包含字符串。我檢查了它的VC運行時。原因是vector包含與異常相關的頭文件。 – Paranaix

+0

用於檢查 – nurettin

相關問題