想法:我想要一个数据结构来保存单词中字符和字符数的多个键/对值。这样,在#34;字符计数中设置了5个字符数"通过计算给定单词的字符数,我可以快速判断集合中是否存在字谜。
问题:我在尝试将unordered_map<char, int>
插入unordered_set<unordered_map<char, int>>
时收到错误。
代码:
#include <unordered_map>
#include <unordered_set>
int main()
{
std::unordered_set<std::unordered_map<char, int>> used_char_counts;
std::unordered_map<char, int> char_counts;
used_char_counts.insert(char_counts);
}
错误:
error: no matching function for call to 'std::unordered_set<std::unordered_map<char, int> >::insert(std::unordered_map<char, int>*)'
编译器版本:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)