컴파일 에러는 컴파일 에러라고 적힌 곳을 눌러보면 그 이유를 알 수있어요
1181번 - 단어 정렬
컴파일 에러는 컴파일 에러라고 적힌 곳을 눌러보면 그 이유를 알 수있어요
In file included from gcc-11.1.0/include/c++/11.1.0/set:60,
from Main.cc:6:
gcc-11.1.0/include/c++/11.1.0/bits/stl_tree.h: In instantiation of ‘static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Identity<std::__cxx11::basic_string<char> >; _Compare = compare; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<std::__cxx11::basic_string<char> >*]’:
gcc-11.1.0/include/c++/11.1.0/bits/stl_tree.h:2069:47: required from ‘std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Identity<std::__cxx11::basic_string<char> >; _Compare = compare; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = std::__cxx11::basic_string<char>]’
gcc-11.1.0/include/c++/11.1.0/bits/stl_tree.h:2122:4: required from ‘std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const std::__cxx11::basic_string<char>&; _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Identity<std::__cxx11::basic_string<char> >; _Compare = compare; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]’
gcc-11.1.0/include/c++/11.1.0/bits/stl_set.h:512:25: required from ‘std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::__cxx11::basic_string<char>; _Compare = compare; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char>, std::_Identity<std::__cxx11::basic_string<char> >, compare, std::allocator<std::__cxx11::basic_string<char> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<_Key>::other = std::allocator<std::__cxx11::basic_string<char> >; typename __gnu_cxx::__alloc_traits<_Allocator>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::rebind<std::__cxx11::basic_string<char> >; typename _Allocator::value_type = std::__cxx11::basic_string<char>; std::set<_Key, _Compare, _Alloc>::value_type = std::__cxx11::basic_string<char>]’
Main.cc:29:13: required from here
gcc-11.1.0/include/c++/11.1.0/bits/stl_tree.h:770:15: error: static assertion failed: comparison object must be invocable as const
770 | is_invocable_v<const _Compare&, const _Key&, const _Key&>,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gcc-11.1.0/include/c++/11.1.0/bits/stl_tree.h:770:15: note: ‘std::is_invocable_v<const compare&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>’ evaluates to false
이렇게 나왔는데 그 뜻을 잘 모르겠습니다..
저도 자세히는 모르지만, 17번 라인을 아래와 같이 수정하니 통과되었습니다.
"comparison object must be invocable as const" 이 부분에 단서가 있는 것 같네요.
그와 별개로, sync_with_stdio(false)를 하면 scanf와 cin을 혼용해서는 안됩니다.
아하 정말 감사합니다! 해결되었습니다!
댓글을 작성하려면 로그인해야 합니다.
daonkim462 3년 전
제가 쓰는 온라인 ide replit에서는 제대로 작동이 되는데 백준에 제출하면 컴파일 에러가 뜨네요ㅠㅠ 그 이유를 모르겠습니다ㅠㅠ