1.#include"stdio.h"
2.#include"sparsepp-master/sparsepp.h"
3.int main()
4.{
5. spp::sparse_hash_map
6.mp.insert(std::make_pair(std::make_pair(1,1),1));
7.return 0;
8.}
这个程序时使用sparsepp库提供的hash版map来存数据的例子,但他有一个错误:库中并没有给出为std::pair
理想情况下我们想要编译器这么提示我们:“亲爱的程序员,您的程序这里有错,错误原因和解决方法我都给你标注好了,么么嗒~~~”
具体错误提示大概长这样:
line 6:mp.insert(std::make_pair(std::make_pair(1,1),1));
^^^^^^^^^^^^^^^^^^^ can't generate serialization
但实际上有点困难,一般编译器只会这么提示我们:“吔屎啦,这里这里这里这里这里这里我都看不懂,赶紧给老娘改!”
JAVA和javascript就喜欢这么干,错误提示大概长这样:
In file sparsepp-master/sparsepp.h:1483:42: XXXXXX
In file sparsepp-master/sparsepp.h:5069:77: XXXXXX
In file main.cpp:6:25: type cast failed
In file main.cpp:3:1: XXXXX
而混乱邪恶的C++是这样提示我们的:
In file included from main.cpp:2:0:
sparsepp-master/sparsepp.h: In instantiation of 'size_t spp::spp_hash
sparsepp-master/sparsepp.h:1483:42: required from 'size_t spp::sparsehash_internal::sh_hashtable_settings
sparsepp-master/sparsepp.h:4729:31: required from 'size_t spp::sparse_hashtable
sparsepp-master/sparsepp.h:4242:33: required from 'spp::sparse_hashtable
sparsepp-master/sparsepp.h:4401:38: required from 'std::pair
sparsepp-master/sparsepp.h:4451:36: required from 'std::pair
sparsepp-master/sparsepp.h:5069:77: required from 'std::pair
main.cpp:6:49: required from here
sparsepp-master/sparsepp.h:943:27: error: use of deleted function 'std::hash
SPP_HASH_CLASS
^~~~~~
In file included from E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/basic_string.h:5628:0,
from E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/string:52,
from sparsepp-master/sparsepp.h:839,
from main.cpp:2:
E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/functional_hash.h:85:12: note: 'std::hash
struct hash : __hash_enum<_Tp>
^~~~
E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/functional_hash.h:85:12: error: no matching function for call to 'std::__hash_enum
E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/functional_hash.h:66:7: note: candidate: std::__hash_enum<_Tp,
__hash_enum(__hash_enum&&);
^~~~~~~~~~~
E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/functional_hash.h:66:7: note: candidate expects 1 argument, 0 provided
E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/functional_hash.h:85:12: error: 'std::__hash_enum<_Tp,
struct hash : __hash_enum<_Tp>
^~~~
E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/functional_hash.h:67:7: note: declared private here
~__hash_enum();
^
In file included from main.cpp:2:0:
sparsepp-master/sparsepp.h:943:27: error: use of deleted function 'std::hash
SPP_HASH_CLASS
^~~~~~
In file included from E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/basic_string.h:5628:0,
from E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/string:52,
from sparsepp-master/sparsepp.h:839,
from main.cpp:2:
E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/functional_hash.h:85:12: note: 'std::hash
struct hash : __hash_enum<_Tp>
^~~~
E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/functional_hash.h:85:12: error: 'std::__hash_enum<_Tp,
E:/mingw-w64/x86_64-6.3.0-posix-seh-rt_v5-rev2/mingw64/lib/gcc/x86_64-w64-mingw32/6.3.0/include/c++/bits/functional_hash.h:67:7: note: declared private here
~__hash_enum();
^
In file included from main.cpp:2:0:
sparsepp-master/sparsepp.h:944:22: error: no match for call to '(std::hash
return hasher(__v);
~~~~~~^~~~~
☻☺这只是一段代码报错时候弹出的提示,当你想像一下一句话报错就能出现这么长的代码,当一个程序出现问题的时候,你找个错误都得找半天,所以大部分人都会选择修复bug然后就出现了更多的bug。