我是C ++的初学者,必须从事一个项目。提供以下代码(头文件),当我导入它时,出现名称空间Utils错误。
public class MyViewModel extends AndroidViewModel {
private List<String> placeOfBirthList;
public MyViewModel(Application application) {
super(application);
myMethod();
}
private void myMethod() {
AutoCompleteCountryAdapter myAdapter = new AutoCompleteCountryAdapter(getApplication().getApplicationContext(), android.R.layout.simple_dropdown_item_1line, placeOfBirthList);
}
}
错误是。
namespace Utils::iterators {
struct RetrieveKey {
template<typename T>
typename T::first_type operator()(T keyValuePair) const {
return keyValuePair.first;
}
};
我只导入了boost库。
这些错误我已经忙了好几个小时了,如果有人能告诉我这个错误的可能原因,那将是一个很大的帮助。
答案 0 :(得分:1)
请确保您正在使用C ++ 17进行编译,因为您的标头使用了嵌套的命名空间说明符(例如namespace Utils::iterators { ... }
)。
对于GCC / clang,可以使用-std=c++17
标志,对于MSVC,可以使用/std:c++latest
标志。