Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: ‘list’ is not a member of ‘std’ and error: template argument 2 is invalid

I'm trying to compile my header file, but I'm getting errors I can't figure out.

I want to create a struct that contains 3 maps: -map from single words to counts -map from word pairs to counts -map from single words to list of following words

The code in my header file:

#include <cstdlib>
#include <iostream>
#include <cstring>
#include <string>
#include <cctype>
#include <vector>
#include <algorithm>
#include <map>

typedef struct {

    std::map<std::string, int> firstCounts;
    std::map<std::string, int> pairCounts;
    std::map<std::string, std::list<std::string>> follows; //You can use an iterator to retrieve the values stored in the list. 

} LanguageModel;

And the errors I'm getting:

>   LangModel.h:24:23: error: ‘list’ is not a member of ‘std’
>      std::map<std::string, std::list<std::string>> follows; //You can use an iterator to retrieve the values stored in the list. 
>                            ^
>     LangModel.h:24:23: error: ‘list’ is not a member of ‘std’
>     LangModel.h:24:38: error: template argument 2 is invalid
>      std::map<std::string, std::list<std::string>> follows; //You can use an iterator to retrieve the values stored in the list. 
>                                           ^
>     LangModel.h:24:38: error: template argument 4 is invalid
>     LangModel.h:24:44: error: expected unqualified-id before ‘>’ token
>      std::map<std::string, std::list<std::string>> follows; //You can use an iterator to retrieve the values stored in the list.
like image 860
NewToThis Avatar asked Apr 01 '15 22:04

NewToThis


2 Answers

You forgot to add

#include <list>    
like image 93
R Sahu Avatar answered Oct 25 '22 12:10

R Sahu


What about #include <list>? You are missing the header inclusion.

like image 25
cadaniluk Avatar answered Oct 25 '22 11:10

cadaniluk