对于一个无序映射,我通过以下方式设置初始bucket计数:
unordered_map<string, dictionaryWord> dictionary(17749); // set initial bucket count to 17749
这种方式似乎不适用于无序集合。
/*line 150*/ unsigned char mask;
/*line 151*/ unordered_set<QueryID> query_id(109); // set initial bucket count to 109
编译器错误=
1) 数字常量之前应为标识符。
2) 应为,或。。。在数字常量之前。
然后又犯了一堆错误
如何对一个未定义的集合做同样的事情?
非常感谢。
=================================================
如果我删除“(109)”,则没有错误
"/usr/bin/make" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/home/petros/NetBeansProjects/ACM_test'
rm -f -r build/Release
rm -f dist/Release/GNU-Linux-x86/acm_test
make[1]: Leaving directory `/home/petros/NetBeansProjects/ACM_test'
CLEAN SUCCESSFUL (total time: 80ms)
"/usr/bin/make" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/petros/NetBeansProjects/ACM_test'
"/usr/bin/make" -f nbproject/Makefile-Release.mk dist/Release/GNU-Linux-x86/acm_test
make[2]: Entering directory `/home/petros/NetBeansProjects/ACM_test'
mkdir -p build/Release/GNU-Linux-x86/ref_impl
rm -f build/Release/GNU-Linux-x86/ref_impl/core.o.d
g++ -pthread -O3 -std=c++11 -c -O2 -pthread -O3 -std=c++11 -MMD -MP -MF build/Release/GNU-Linux-x86/ref_impl/core.o.d -o build/Release/GNU-Linux-x86/ref_impl/core.o ref_impl/core.cpp
ref_impl/core.cpp:151:37: error: expected identifier before numeric constant
ref_impl/core.cpp:151:37: error: expected â,â or â...â before numeric constant
ref_impl/core.cpp: In function âErrorCode StartQuery(QueryID, const char*, MatchType, unsigned int)â:
ref_impl/core.cpp:250:24: error: expected unqualified-id before â(â token
ref_impl/core.cpp:250:38: error: missing template arguments before â)â token
ref_impl/core.cpp:250:39: error: expected â;â before âquery_idâ
ref_impl/core.cpp:257:19: error: âquery.SameQueries::query_idâ does not have class type
ref_impl/core.cpp: In function âErrorCode EndQuery(QueryID)â:
ref_impl/core.cpp:265:44: error: âqueries.std::vector<_Tp, _Alloc>::operator[]<SameQueries, std::allocator<SameQueries> >(((std::vector<SameQueries>::size_type)i)).SameQueries::query_idâ does not have class type
ref_impl/core.cpp:265:58: error: unable to deduce âconst autoâ from â<expression error>â
ref_impl/core.cpp:266:38: error: âqueries.std::vector<_Tp, _Alloc>::operator[]<SameQueries, std::allocator<SameQueries> >(((std::vector<SameQueries>::size_type)i)).SameQueries::query_idâ does not have class type
ref_impl/core.cpp:267:32: error: âqueries.std::vector<_Tp, _Alloc>::operator[]<SameQueries, std::allocator<SameQueries> >(((std::vector<SameQueries>::size_type)i)).SameQueries::query_idâ does not have class type
ref_impl/core.cpp:268:36: error: âqueries.std::vector<_Tp, _Alloc>::operator[]<SameQueries, std::allocator<SameQueries> >(((std::vector<SameQueries>::size_type)i)).SameQueries::query_idâ does not have class type
ref_impl/core.cpp: In function âvoid* TaskCode(void*)â:
ref_impl/core.cpp:463:41: error: âquer.SameQueries::query_idâ does not have class type
ref_impl/core.cpp:463:48: error: unable to deduce âautoâ from â<expression error>â
ref_impl/core.cpp:463:70: error: âquer.SameQueries::query_idâ does not have class type
make[2]: *** [build/Release/GNU-Linux-x86/ref_impl/core.o] Error 1
make[2]: Leaving directory `/home/petros/NetBeansProjects/ACM_test'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/petros/NetBeansProjects/ACM_test'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)