珍爱生命远离c++就是这么来的

珍爱⽣命远离c++就是这么来的
1.#include"stdio.h"
学知网
2.#include"sparsepp-master/sparsepp.h"
3.int main()2012奥运羽毛球男双决赛
4.{
5. spp::sparse_hash_map<std::pair<int,int>,int> mp;
6.mp.insert(std::make_pair(std::make_pair(1,1),1));
8.}
这个程序时使⽤sparsepp库提供的hash版map来存数据的例⼦,但他有⼀个错误:库中并没有给出为std::pair<int,int>产⽣hash值的算法,因此该程序不能⼯作。
理想情况下我们想要编译器这么提⽰我们:“亲爱的程序员,您的程序这⾥有错,错误原因和解决⽅法我都给你标注好了,么么嗒
~~~”
具体错误提⽰⼤概长这样:
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<T>::operator()(const T&) const [with T = std::pair<int, int>; size_t = long long unsigned int]':
sparsepp-master/sparsepp.h:1483:42:  required from 'size_t spp::sparsehash_internal::sh_hashtable_settings<Key, HashFunc, SizeType, HT_MIN_BUCKETS>::hash(const key_type&) const [with Key = std::pair<int, int>; HashFunc =
spp::spp_hash<std::pair<int, int> >; SizeType = long long unsigned int; int HT_MIN_BUCKETS = 4; size_t = long long unsigned int; spp::sparsehash_internal::sh_hashtable_settings<Key, HashFunc, SizeType, HT_MIN_BUCKETS>::key_type = std::pair<int, int>]'
sparsepp-master/sparsepp.h:4729:31:  required from 'size_t spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::hash(const key_type&) const [with Value = std::pair<std::pair<int, int>, int>; Key = std::pair<int, int>; HashFcn = spp::spp_hash<std::pair<int, int
> >; ExtractKey = spp::sparse_hash_map<std::pair<int, int>, int>::SelectKey; SetKey =
spp::sparse_hash_map<std::pair<int, int>, int>::SetKey; EqualKey = std::equal_to<std::pair<int, int> >; Alloc =
spp::libc_allocator_with_realloc<std::pair<const std::pair<int, int>, int> >; size_t = long long unsigned int;
spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::key_type = std::pair<int, int>]'
造纸分散剂sparsepp-master/sparsepp.h:4242:33:  required from 'spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::Position spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::_find_position(const key_type&) const [with Value = std::pair<std::pair<int, int>, int>; Key = std::pair<int, int>; HashFcn = spp::spp_hash<std::pair<int, int> >; ExtractKey = spp::sparse_hash_map<std::pair<int, int>, int>::SelectKey; SetKey = spp::sparse_hash_map<std::pair<int, int>, int>::SetKey; EqualKey = std::equal_to<std::pair<int, int> >; Alloc = spp::libc_allocator_with_realloc<std::pair<const std::pair<int, int>, int> >; spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::key_type = std::
pair<int, int>]'
sparsepp-master/sparsepp.h:4401:38:  required from 'std::pair<typename spp::sparsetable<Value, typename
Alloc::rebind<Value>::other>::ne_iterator, bool> spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::_insert_noresize(T&) [with T = const std::pair<const std::pair<int, int>, int>; Value = std::pair<std::pair<int, int>, int>; Key = std::pair<int, int>; HashFcn = spp::spp_hash<std::pair<int, int> >; ExtractKey = spp::sparse_hash_map<std::pair<int, int>,
int>::SelectKey; SetKey = spp::sparse_hash_map<std::pair<int, int>, int>::SetKey; EqualKey = std::equal_to<std::pair<int, int> >; Alloc = spp::libc_allocator_with_realloc<std::pair<const std::pair<int, int>, int> >; typename spp::sparsetable<Value, typename
Alloc::rebind<Value>::other>::ne_iterator = spp::Two_d_iterator<std::pair<std::pair<int, int>, int>,
spp::sparsegroup<std::pair<std::pair<int, int>, int>, spp::libc_allocator_with_realloc<std::pair<std::pair<int, int>, int> > >*,
std::pair<const std::pair<int, int>, int>*, std::bidirectional_iterator_tag>]'
sparsepp-master/sparsepp.h:4451:36:  required from 'std::pair<typename spp::sparsetable<Value, typename
Alloc::rebind<Value>::other>::ne_iterator, bool> spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::insert(spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::const_reference) [with Value = std::pair<std::pair<int, int>, int>; Key = std::pair<int, int>; HashFcn = spp::spp_hash<std::pair<int, int> >; ExtractKey =
spp::sparse_hash_map<std::pair<int, int>, int>::SelectKey; SetKey = spp::sparse_hash_map<std::pair<int, int>, int>::SetKey; EqualKey = std::equal_to<std::pair<int, int> >; Alloc = spp::libc_allocator_with_realloc<std::pair<const std::pair<int, int>, int> >; typename spp::sparsetable<Value, typename Alloc::rebind<Value>::other>::ne_iterator = spp::Two_d_iterator<std::pair<std::pair<int, int>, int>, spp::sparsegroup<std::pair<std::pair<int, int>, int>, spp::libc_allocator_with_realloc<std::pair<std::pair<int, int>, int> > >*, std::pair<const std::pair<int, int>, int>*, std::bidirectional_iterator_tag>; spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::const_reference = const std::pair<const std::pair<int, int>, int>&; spp::sparse_hashtable<Value, Key, HashFcn, ExtractKey, SetKey, EqualKey, Alloc>::value_type = std::pair<const std::pair<int, int>, int>]'
sparsepp-master/sparsepp.h:5069:77:  required from 'std::pair<typename spp::sparse_hashtable<std::pair<typename
spp::remove_const<Key>::type, T>, Key, HashFcn, spp::sparse_hash_map<Key, T, HashFcn, EqualKey, Alloc>::SelectKey,
词牌名 春spp::sparse_hash_map<Key, T, HashFcn, EqualKey, Alloc>::SetKey, EqualKey, Alloc>::iterator, bool> spp::sparse_hash_map<Key, T, HashFcn, EqualKey, Alloc>::insert(const value_type&) [with Key = std::pair<int, int>; T = int; HashFcn =
spp::spp_hash<std::pair<int, int> >; EqualKey = std::equal_to<std::pair<int, int> >; Alloc =
spp::libc_allocator_with_realloc<std::pair<const std::pair<int, int>, int> >; typename spp::sparse_hashtable<std::pair<typename spp::remove_const<Key>::type, T>, Key, HashFcn, spp::sparse_hash_map<Key, T, HashFcn, EqualKey, Alloc>::SelectKey,
spp::sparse_hash_map<Key, T, HashFcn, EqualKey, Alloc>::SetKey, EqualKey, Alloc>::iterator =
spp::Two_d_iterator<std::pair<std::pair<int, int>, int>, spp::sparsegroup<std::pair<std::pair<int, int>, int>,
spp::libc_allocator_with_realloc<std::pair<std::pair<int, int>, int> > >*, std::pair<const std::pair<int, int>, int>*,
std::bidirectional_iterator_tag>; spp::sparse_hash_map<Key, T, HashFcn, EqualKey, Alloc>::value_type = std::pair<const
std::pair<int, int>, int>]'
main.cpp:6:49:  required from here
sparsepp-master/sparsepp.h:943:27: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()'
SPP_HASH_CLASS<T> hasher;
^~~~~~
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<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed:
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<std::pair<int, int>, false>::__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, <anonymous>
>::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]
__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, <anonymous> >::~__hash_enum() [with
_Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context
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<std::pair<int, int> >::~hash()'
SPP_HASH_CLASS<T> hasher;
^~~~~~
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<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed:
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, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context
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<std::pair<int, int> >) (const std::pair<int, int>&)'
return hasher(__v);
~~~~~~^~~~~
☻☺这只是⼀段代码报错时候弹出的提⽰,当你想像⼀下⼀句话报错就能出现这么长的代码,当⼀个程序出现问题的时候,你个错误都得半天,所以⼤部分⼈都会选择修复bug然后就出现了更多的bug。

本文发布于:2024-09-21 19:25:58,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/473581.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:错误   程序   出现   时候   想要   情况
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议