Creating std::map with a structure as its key and value [duplicate] - c++

This question already has answers here:
Error using custom operator< with std::less
(2 answers)
Closed 4 years ago.
I want to define a static map inside a class, which will have a structure as both it's key and value. I've read that a '<' operator is needed to be defined, therefore I've included that definition inside the struct itself(I've randomly defined it as I don't need any comparison anywhere in my program).
The below sample code doesn't compile.The compiler produces a lot of warnings and errors which I don't understand right now. (Please ignore the uninitialized values in the main function):
#include<string>
#include<iostream>
#include<map>
using namespace std;
struct RJNodeAddress
{
string m_ip;
string m_port;
bool operator<(const RJNodeAddress &l)
{
int l_size=l.m_ip.size();
int r_size=l.m_port.size();
return (l_size < r_size);
}
};
struct RJNodeDetails
{
string m_NodeType;
int m_appId;
};
class RJWebsocket
{
public:
static map<RJNodeAddress,RJNodeDetails> m_Nodes;
};
int main()
{
RJNodeAddress l_node;
RJNodeDetails l_nodeDetails = RJWebsocket::m_Nodes[l_node];
}
Compiler output
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h: In instantiation of âconstexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = RJNodeAddress]â:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_map.h:491:32: required from âstd::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = RJNodeAddress; _Tp = RJNodeDetails; _Compare = std::less<RJNodeAddress>; _Alloc = std::allocator<std::pair<const RJNodeAddress, RJNodeDetails> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = RJNodeDetails; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = RJNodeAddress]â
test.cpp:34:59: required from here
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: error: no match for âoperator<â (operand types are âconst RJNodeAddressâ and âconst RJNodeAddressâ)
{ return __x < __y; }
~~~~^~~~~
test.cpp:10:14: note: candidate: bool RJNodeAddress::operator<(const RJNodeAddress&) <near match>
bool operator<(const RJNodeAddress &l)
^~~~~~~~
test.cpp:10:14: note: passing âconst RJNodeAddress*â as âthisâ argument discards qualifiers
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_algobase.h:64:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/char_traits.h:39,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:40,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_pair.h:449:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_pair.h:449:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::pair<_T1, _T2>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_algobase.h:67:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/char_traits.h:39,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:40,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_iterator.h:305:5: note: candidate: template<class _Iterator> constexpr bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator<(const reverse_iterator<_Iterator>& __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_iterator.h:305:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::reverse_iterator<_Iterator>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_algobase.h:67:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/char_traits.h:39,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:40,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_iterator.h:343:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator<(const reverse_iterator<_IteratorL>& __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_iterator.h:343:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::reverse_iterator<_Iterator>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_algobase.h:67:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/char_traits.h:39,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:40,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_iterator.h:1142:5: note: candidate: template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)
operator<(const move_iterator<_IteratorL>& __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_iterator.h:1142:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::move_iterator<_IteratorL>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_algobase.h:67:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/char_traits.h:39,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:40,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_iterator.h:1148:5: note: candidate: template<class _Iterator> constexpr bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&)
operator<(const move_iterator<_Iterator>& __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_iterator.h:1148:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::move_iterator<_IteratorL>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.h:48:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:52,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/string_view:485:5: note: candidate: template<class _CharT, class _Traits> bool std::operator<(std::basic_string_view<_CharT, _Traits>, std::basic_string_view<_CharT, _Traits>)
operator< (basic_string_view<_CharT, _Traits> __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/string_view:485:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âRJNodeAddressâ is not derived from âstd::basic_string_view<_CharT, _Traits>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.h:48:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:52,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/string_view:491:5: note: candidate: template<class _CharT, class _Traits> bool std::operator<(std::basic_string_view<_CharT, _Traits>, std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >)
operator< (basic_string_view<_CharT, _Traits> __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/string_view:491:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âRJNodeAddressâ is not derived from âstd::basic_string_view<_CharT, _Traits>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.h:48:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:52,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/string_view:497:5: note: candidate: template<class _CharT, class _Traits> bool std::operator<(std::__detail::__idt<std::basic_string_view<_CharT, _Traits> >, std::basic_string_view<_CharT, _Traits>)
operator< (__detail::__idt<basic_string_view<_CharT, _Traits>> __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/string_view:497:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âRJNodeAddressâ is not derived from âstd::basic_string_view<_CharT, _Traits>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:52:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.h:5892:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.h:5892:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::basic_string<_CharT, _Traits, _Alloc>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:52:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.h:5905:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.h:5905:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::basic_string<_CharT, _Traits, _Alloc>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:52:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.h:5917:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const _CharT* __lhs,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/basic_string.h:5917:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: mismatched types âconst _CharT*â and âRJNodeAddressâ
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/ios_base.h:46:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/ios:42,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/ostream:38,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/iostream:39,
from test.cpp:2:
/opt/rh/devtoolset-7/root/usr/include/c++/7/system_error:208:3: note: candidate: bool std::operator<(const std::error_code&, const std::error_code&)
operator<(const error_code& __lhs, const error_code& __rhs) noexcept
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/system_error:208:3: note: no known conversion for argument 1 from âconst RJNodeAddressâ to âconst std::error_code&â
/opt/rh/devtoolset-7/root/usr/include/c++/7/system_error:282:3: note: candidate: bool std::operator<(const std::error_condition&, const std::error_condition&)
operator<(const error_condition& __lhs,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/system_error:282:3: note: no known conversion for argument 1 from âconst RJNodeAddressâ to âconst std::error_condition&â
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/node_handle.h:39:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:72,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:60,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:808:5: note: candidate: template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Tp>() < declval<_Up>()))> std::operator<(const std::optional<_Tp>&, const std::optional<_Up>&)
operator<(const optional<_Tp>& __lhs, const optional<_Up>& __rhs)
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:808:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::optional<_Tp>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/node_handle.h:39:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:72,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:60,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:861:5: note: candidate: template<class _Tp> constexpr bool std::operator<(const std::optional<_Tp>&, std::nullopt_t)
operator<(const optional<_Tp>& /* __lhs */, nullopt_t) noexcept
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:861:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::optional<_Tp>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/node_handle.h:39:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:72,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:60,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:866:5: note: candidate: template<class _Tp> constexpr bool std::operator<(std::nullopt_t, const std::optional<_Tp>&)
operator<(nullopt_t, const optional<_Tp>& __rhs) noexcept
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:866:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::optional<_Tp>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/node_handle.h:39:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:72,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:60,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:926:5: note: candidate: template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Tp>() < declval<_Up>()))> std::operator<(const std::optional<_Tp>&, const _Up&)
operator<(const optional<_Tp>& __lhs, const _Up& __rhs)
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:926:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::optional<_Tp>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/node_handle.h:39:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:72,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:60,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:932:5: note: candidate: template<class _Tp, class _Up> constexpr std::__optional_relop_t<decltype ((declval<_Up>() < declval<_Tp>()))> std::operator<(const _Up&, const std::optional<_Tp>&)
operator<(const _Up& __lhs, const optional<_Tp>& __rhs)
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/optional:932:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::optional<_Tp>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/tuple:39:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/node_handle.h:40,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:72,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:60,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/array:262:5: note: candidate: template<class _Tp, long unsigned int _Nm> bool std::operator<(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/array:262:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::array<_Tp, _Nm>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/node_handle.h:40:0,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:72,
from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:60,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/tuple:1410:5: note: candidate: template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const std::tuple<_Tps ...>&, const std::tuple<_Elements ...>&)
operator<(const tuple<_TElements...>& __t,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/tuple:1410:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::tuple<_Tps ...>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:60:0,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:1543:5: note: candidate: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator<(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_tree.h:1543:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:61:0,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_map.h:1397:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)
operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_map.h:1397:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::map<_Key, _Tp, _Compare, _Alloc>â
{ return __x < __y; }
~~~~^~~~~
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/map:62:0,
from test.cpp:3:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_multimap.h:1062:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
^~~~~~~~
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_multimap.h:1062:5: note: template argument deduction/substitution failed:
In file included from /opt/rh/devtoolset-7/root/usr/include/c++/7/string:48:0,
from test.cpp:1:
/opt/rh/devtoolset-7/root/usr/include/c++/7/bits/stl_function.h:386:20: note: âconst RJNodeAddressâ is not derived from âconst std::multimap<_Key, _Tp, _Compare, _Alloc>â
{ return __x < __y; }
~~~~^~~~~

As keys in std::map are const your operator< method must be const as well:
bool operator<(const RJNodeAddress &l) const
// ^ here
it should be const anyway as it does not modify the object but in this case missing it leads to compilation errors.

Related

How to add struct, vector of struct to map within class

My issue is in the following .h:
#include <iostream>
#include <map>
#include <vector>
struct Node {
int data;
};
class Graph {
std::map< Node, std::vector<Node> > edge_map;
public:
Graph();
void add_neighbor(Node cur_node, Node new_node);
void remove_neighbor(Node cur_node, Node del_node);
virtual ~Graph();
};
and in trying to implement the add_neighbor function, but I'm fumbling through the details and need some direction. What I've got so far (not functional) is the following:
void Graph::add_neighbor(Node cur_node, Node new_node) {
if (edge_map.find(cur_node) == edge_map.end()) {
edge_map.insert(std::pair<Node, std::vector<Node> >(cur_node, std::vector<Node>()));
edge_map[cur_node].push_back(new_node);
}
else {
edge_map[cur_node].push_back(new_node);
}
}
I can copy the explosion that g++ -std=c++11 throws at me, but it's not very helpful. How can I include a map as a class member where the key, value are struct, vector of struct, and then have a function in the .cpp that can add it? I'll also need the remove function, but once I understand how to treat the data in the insertion function I'll know what I need, I think.
EDIT (including the compiler vomit):
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h: In instantiation of ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Node]’:
/usr/include/c++/4.8/bits/stl_map.h:463:31: required from ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = Node; _Tp = std::vector<Node>; _Compare = std::less<Node>; _Alloc = std::allocator<std::pair<const Node, std::vector<Node> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::vector<Node>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = Node]’
graph.cpp:14:26: required from here
/usr/include/c++/4.8/bits/stl_function.h:235:20: error: no match for ‘operator<’ (operand types are ‘const Node’ and ‘const Node’)
{ return __x < __y; }
^
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: candidates are:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_pair.h:220:5: note: template<class _T1, class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
/usr/include/c++/4.8/bits/stl_pair.h:220:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::pair<_T1, _T2>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:297:5: note: template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator<(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:297:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::reverse_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:347:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator<(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:347:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::reverse_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1055:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
operator<(const move_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:1055:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::move_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/char_traits.h:39,
from /usr/include/c++/4.8/ios:40,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1061:5: note: template<class _Iterator> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
operator<(const move_iterator<_Iterator>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:1061:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::move_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:2569:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2569:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:2581:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2581:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/basic_string.h:2593:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const _CharT* __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2593:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: mismatched types ‘const _CharT*’ and ‘Node’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/vector:64:0,
from graph.cpp:2:
/usr/include/c++/4.8/bits/stl_vector.h:1421:5: note: template<class _Tp, class _Alloc> bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
^
/usr/include/c++/4.8/bits/stl_vector.h:1421:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::vector<_Tp, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/tuple:39:0,
from /usr/include/c++/4.8/functional:55,
from /usr/include/c++/4.8/bits/stl_algo.h:66,
from /usr/include/c++/4.8/algorithm:62,
from graph.cpp:3:
/usr/include/c++/4.8/array:238:5: note: template<class _Tp, long unsigned int _Nm> bool std::operator<(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
^
/usr/include/c++/4.8/array:238:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::array<_Tp, _Nm>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/functional:55:0,
from /usr/include/c++/4.8/bits/stl_algo.h:66,
from /usr/include/c++/4.8/algorithm:62,
from graph.cpp:3:
/usr/include/c++/4.8/tuple:824:5: note: template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const std::tuple<_Elements ...>&, const std::tuple<_Elements ...>&)
operator<(const tuple<_TElements...>& __t,
^
/usr/include/c++/4.8/tuple:824:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::tuple<_Elements ...>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/map:60:0,
from graph.h:2,
from graph.cpp:4:
/usr/include/c++/4.8/bits/stl_tree.h:917:5: note: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator<(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
^
/usr/include/c++/4.8/bits/stl_tree.h:917:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/map:61:0,
from graph.h:2,
from graph.cpp:4:
/usr/include/c++/4.8/bits/stl_map.h:979:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)
operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
^
/usr/include/c++/4.8/bits/stl_map.h:979:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::map<_Key, _Tp, _Compare, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/map:62:0,
from graph.h:2,
from graph.cpp:4:
/usr/include/c++/4.8/bits/stl_multimap.h:881:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
^
/usr/include/c++/4.8/bits/stl_multimap.h:881:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/string:48:0,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from graph.cpp:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Node’ is not derived from ‘const std::multimap<_Key, _Tp, _Compare, _Alloc>’
{ return __x < __y; }
^
In order for std::map to order it's entrys, it requires an operator<.
In your case, it can be as simple as this:
bool operator<(const Node & left, const Node & right)
{
return left.data < right.data;
}

g++ ultra verbosity nightmare

This is for a single error. I had to cut it down in order to post it here. How to disable this madness ? (g++ 5.3.1)
user#computer:~/projectClient# ./build
project/update.cpp: In function ‘bool is_recentlyProcessed(IntervalTime, ulong)’:
project/update.cpp:71:80: error: no match for ‘operator==’ (operand types are ‘std::_Rb_tree_const_iterator<long unsigned int>’ and ‘std::map<IntervalTime, std::set<long unsigned int> >::iterator {aka std::_Rb_tree_iterator<std::pair<const IntervalTime, std::set<long unsigned int> > >}’)
return !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end
^
In file included from /usr/include/c++/5/set:60:0,
from project/update.cpp:6:
/usr/include/c++/5/bits/stl_tree.h:312:7: note: candidate: bool std::_Rb_tree_const_iterator<_Tp>::operator==(const _Self&) const [with _Tp = long unsigned int; std::_Rb_tree_const_iterator<_Tp>::_Self = std::_Rb_tree_const_iterator<long unsigned int>]
operator==(const _Self& __x) const _GLIBCXX_NOEXCEPT
^
/usr/include/c++/5/bits/stl_tree.h:312:7: note: no known conversion for argument 1 from ‘std::map<IntervalTime, std::set<long unsigned int> >::iterator {aka std::_Rb_tree_iterator<std::pair<const IntervalTime, std::set<long unsigned int> > >}’ to ‘const _Self& {aka const std::_Rb_tree_const_iterator<long unsigned int>&}’
In file included from /usr/include/c++/5/stack:61:0,
from /usr/include/jsoncpp/json/reader.h:15,
from /usr/include/jsoncpp/json/json.h:11,
from project/../parser/parser.h:5,
from project/../data.h:5,
from project/update.cpp:12:
/usr/include/c++/5/bits/stl_stack.h:246:5: note: candidate: template<class _Tp, class _Seq> bool std::operator==(const std::stack<_Tp, _Seq>&, const std::stack<_Tp, _Seq>&)
operator==(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
^
/usr/include/c++/5/bits/stl_stack.h:246:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::stack<_Tp, _Seq>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/deque:64:0,
from /usr/include/jsoncpp/json/reader.h:13,
from /usr/include/jsoncpp/json/json.h:11,
from project/../parser/parser.h:5,
from project/../data.h:5,
from project/update.cpp:12:
/usr/include/c++/5/bits/stl_deque.h:2220:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator==(const std::deque<_Tp, _Alloc>&, const std::deque<_Tp, _Alloc>&)
operator==(const deque<_Tp, _Alloc>& __x,
^
/usr/include/c++/5/bits/stl_deque.h:2220:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::deque<_Tp, _Alloc>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/deque:64:0,
from /usr/include/jsoncpp/json/reader.h:13,
from /usr/include/jsoncpp/json/json.h:11,
from project/../parser/parser.h:5,
from project/../data.h:5,
from project/update.cpp:12:
/usr/include/c++/5/bits/stl_deque.h:272:5: note: candidate: template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> bool std::operator==(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&)
operator==(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
^
/usr/include/c++/5/bits/stl_deque.h:272:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::_Deque_iterator<_Tp, _Ref, _Ptr>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/deque:64:0,
from /usr/include/jsoncpp/json/reader.h:13,
from /usr/include/jsoncpp/json/json.h:11,
from project/../parser/parser.h:5,
from project/../data.h:5,
from project/update.cpp:12:
/usr/include/c++/5/bits/stl_deque.h:265:5: note: candidate: template<class _Tp, class _Ref, class _Ptr> bool std::operator==(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&)
operator==(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
^
/usr/include/c++/5/bits/stl_deque.h:265:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::_Deque_iterator<_Tp, _Ref, _Ptr>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/map:62:0,
from /usr/include/jsoncpp/json/value.h:17,
from /usr/include/jsoncpp/json/json.h:10,
from project/../parser/parser.h:5,
from project/../data.h:5,
from project/update.cpp:12:
/usr/include/c++/5/bits/stl_multimap.h:974:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator==(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
^
/usr/include/c++/5/bits/stl_multimap.h:974:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::multimap<_Key, _Tp, _Compare, _Alloc>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/map:61:0,
from /usr/include/jsoncpp/json/value.h:17,
from /usr/include/jsoncpp/json/json.h:10,
from project/../parser/parser.h:5,
from project/../data.h:5,
from project/update.cpp:12:
/usr/include/c++/5/bits/stl_map.h:1073:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator==(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)
operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x,
^
/usr/include/c++/5/bits/stl_map.h:1073:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::map<_Key, _Tp, _Compare, _Alloc>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/memory:82:0,
from /usr/include/c++/5/thread:40,
from project/update.cpp:7:
/usr/include/c++/5/bits/shared_ptr.h:347:5: note: candidate: template<class _Tp> bool std::operator==(std::nullptr_t, const std::shared_ptr<_Tp1>&)
operator==(nullptr_t, const shared_ptr<_Tp>& __a) noexcept
^
/usr/include/c++/5/bits/shared_ptr.h:347:5: note: template argument deduction/substitution failed:
project/update.cpp:71:15: note: cannot convert ‘std::find<std::_Rb_tree_const_iterator<long unsigned int>, long unsigned int>((& recentlyProcessed.std::map<_Key, _Tp, _Compare, _Alloc>::operator[]<IntervalTime, std::set<long unsigned int>, std::less<IntervalTime>, std::allocator<std::pair<const IntervalTime, std::set<long unsigned int> > > >(it))->std::set<_Key, _Compare, _Alloc>::begin<long unsigned int, std::less<long unsigned int>, std::allocator<long unsigned int> >(), (& recentlyProcessed.std::map<_Key, _Tp, _Compare, _Alloc>::operator[]<IntervalTime, std::set<long unsigned int>, std::less<IntervalTime>, std::allocator<std::pair<const IntervalTime, std::set<long unsigned int> > > >(it))->std::set<_Key, _Compare, _Alloc>::end<long unsigned int, std::less<long unsigned int>, std::allocator<long unsigned int> >(), id)’ (type ‘std::_Rb_tree_const_iterator<long unsigned int>’) to type ‘std::nullptr_t’
return !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end
^
In file included from /usr/include/c++/5/memory:82:0,
from /usr/include/c++/5/thread:40,
from project/update.cpp:7:
/usr/include/c++/5/bits/shared_ptr.h:342:5: note: candidate: template<class _Tp> bool std::operator==(const std::shared_ptr<_Tp1>&, std::nullptr_t)
operator==(const shared_ptr<_Tp>& __a, nullptr_t) noexcept
^
/usr/include/c++/5/bits/shared_ptr.h:342:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::shared_ptr<_Tp1>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/memory:82:0,
from /usr/include/c++/5/thread:40,
from project/update.cpp:7:
/usr/include/c++/5/bits/shared_ptr.h:336:5: note: candidate: template<class _Tp1, class _Tp2> bool std::operator==(const std::shared_ptr<_Tp1>&, const std::shared_ptr<_Tp2>&)
operator==(const shared_ptr<_Tp1>& __a,
^
/usr/include/c++/5/bits/shared_ptr.h:336:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::shared_ptr<_Tp1>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/bits/shared_ptr.h:52:0,
from /usr/include/c++/5/memory:82,
from /usr/include/c++/5/thread:40,
from project/update.cpp:7:
/usr/include/c++/5/bits/shared_ptr_base.h:1194:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> bool std::operator==(std::nullptr_t, const std::__shared_ptr<_Tp, _Lp>&)
operator==(nullptr_t, const __shared_ptr<_Tp, _Lp>& __a) noexcept
^
/usr/include/c++/5/bits/shared_ptr_base.h:1194:5: note: template argument deduction/substitution failed:
project/update.cpp:71:15: note: cannot convert ‘std::find<std::_Rb_tree_const_iterator<long unsigned int>, long unsigned int>((& recentlyProcessed.std::map<_Key, _Tp, _Compare, _Alloc>::operator[]<IntervalTime, std::set<long unsigned int>, std::less<IntervalTime>, std::allocator<std::pair<const IntervalTime, std::set<long unsigned int> > > >(it))->std::set<_Key, _Compare, _Alloc>::begin<long unsigned int, std::less<long unsigned int>, std::allocator<long unsigned int> >(), (& recentlyProcessed.std::map<_Key, _Tp, _Compare, _Alloc>::operator[]<IntervalTime, std::set<long unsigned int>, std::less<IntervalTime>, std::allocator<std::pair<const IntervalTime, std::set<long unsigned int> > > >(it))->std::set<_Key, _Compare, _Alloc>::end<long unsigned int, std::less<long unsigned int>, std::allocator<long unsigned int> >(), id)’ (type ‘std::_Rb_tree_const_iterator<long unsigned int>’) to type ‘std::nullptr_t’
return !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end
^
In file included from /usr/include/c++/5/bits/shared_ptr.h:52:0,
from /usr/include/c++/5/memory:82,
from /usr/include/c++/5/thread:40,
from project/update.cpp:7:
/usr/include/c++/5/bits/shared_ptr_base.h:1189:5: note: candidate: template<class _Tp, __gnu_cxx::_Lock_policy _Lp> bool std::operator==(const std::__shared_ptr<_Tp, _Lp>&, std::nullptr_t)
operator==(const __shared_ptr<_Tp, _Lp>& __a, nullptr_t) noexcept
^
/usr/include/c++/5/bits/shared_ptr_base.h:1189:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::__shared_ptr<_Tp, _Lp>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/bits/shared_ptr.h:52:0,
from /usr/include/c++/5/memory:82,
from /usr/include/c++/5/thread:40,
from project/update.cpp:7:
/usr/include/c++/5/bits/shared_ptr_base.h:1183:5: note: candidate: template<class _Tp1, class _Tp2, __gnu_cxx::_Lock_policy _Lp> bool std::operator==(const std::__shared_ptr<_Tp1, _Lp>&, const std::__shared_ptr<_Tp2, _Lp>&)
operator==(const __shared_ptr<_Tp1, _Lp>& __a,
^
/usr/include/c++/5/bits/shared_ptr_base.h:1183:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::__shared_ptr<_Tp1, _Lp>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/set:62:0,
from project/update.cpp:6:
/usr/include/c++/5/bits/stl_multiset.h:825:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator==(const std::multiset<_Key, _Compare, _Alloc>&, const std::multiset<_Key, _Compare, _Alloc>&)
operator==(const multiset<_Key, _Compare, _Alloc>& __x,
^
/usr/include/c++/5/bits/stl_multiset.h:825:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::multiset<_Key, _Compare, _Alloc>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/set:61:0,
from project/update.cpp:6:
/usr/include/c++/5/bits/stl_set.h:842:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator==(const std::set<_Key, _Compare, _Alloc>&, const std::set<_Key, _Compare, _Alloc>&)
operator==(const set<_Key, _Compare, _Alloc>& __x,
^
/usr/include/c++/5/bits/stl_set.h:842:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::set<_Key, _Compare, _Alloc>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/set:60:0,
from project/update.cpp:6:
/usr/include/c++/5/bits/stl_tree.h:1273:5: note: candidate: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator==(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
operator==(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
^
/usr/include/c++/5/bits/stl_tree.h:1273:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
....
In file included from /usr/include/c++/5/string:41:0,
from /usr/include/c++/5/random:40,
from /usr/include/c++/5/bits/stl_algo.h:66,
from /usr/include/c++/5/algorithm:62,
from project/update.cpp:1:
/usr/include/c++/5/bits/allocator.h:134:5: note: candidate: template<class _Tp> bool std::operator==(const std::allocator<_Tp>&, const std::allocator<_Tp>&)
operator==(const allocator<_Tp>&, const allocator<_Tp>&)
^
/usr/include/c++/5/bits/allocator.h:134:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::allocator<_Tp>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/string:41:0,
from /usr/include/c++/5/random:40,
from /usr/include/c++/5/bits/stl_algo.h:66,
from /usr/include/c++/5/algorithm:62,
from project/update.cpp:1:
/usr/include/c++/5/bits/allocator.h:128:5: note: candidate: template<class _T1, class _T2> bool std::operator==(const std::allocator<_Tp>&, const std::allocator<_Tp>&)
operator==(const allocator<_T1>&, const allocator<_T2>&)
^
/usr/include/c++/5/bits/allocator.h:128:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::allocator<_Tp>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/bits/char_traits.h:40:0,
from /usr/include/c++/5/string:40,
from /usr/include/c++/5/random:40,
from /usr/include/c++/5/bits/stl_algo.h:66,
from /usr/include/c++/5/algorithm:62,
from project/update.cpp:1:
/usr/include/c++/5/bits/postypes.h:216:5: note: candidate: template<class _StateT> bool std::operator==(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
^
/usr/include/c++/5/bits/postypes.h:216:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::fpos<_StateT>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/algorithm:61,
from project/update.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:1071:5: note: candidate: template<class _Iterator> bool std::operator==(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
operator==(const move_iterator<_Iterator>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:1071:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::move_iterator<_Iterator>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/algorithm:61,
from project/update.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:1065:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
operator==(const move_iterator<_IteratorL>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:1065:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::move_iterator<_Iterator>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/algorithm:61,
from project/update.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:342:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator==(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:342:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::reverse_iterator<_Iterator>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/algorithm:61,
from project/update.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:292:5: note: candidate: template<class _Iterator> bool std::operator==(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator==(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:292:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::reverse_iterator<_Iterator>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/utility:70:0,
from /usr/include/c++/5/algorithm:60,
from project/update.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:214:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator==(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
/usr/include/c++/5/bits/stl_pair.h:214:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const std::pair<_T1, _T2>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h:33:0,
from /usr/include/c++/5/bits/allocator.h:46,
from /usr/include/c++/5/string:41,
from /usr/include/c++/5/random:40,
from /usr/include/c++/5/bits/stl_algo.h:66,
from /usr/include/c++/5/algorithm:62,
from project/update.cpp:1:
/usr/include/c++/5/ext/new_allocator.h:139:5: note: candidate: template<class _Tp> bool __gnu_cxx::operator==(const __gnu_cxx::new_allocator<_Tp>&, const __gnu_cxx::new_allocator<_Tp>&)
operator==(const new_allocator<_Tp>&, const new_allocator<_Tp>&)
^
/usr/include/c++/5/ext/new_allocator.h:139:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const __gnu_cxx::new_allocator<_Tp>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/algorithm:61,
from project/update.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:827:5: note: candidate: template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)
operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
^
/usr/include/c++/5/bits/stl_iterator.h:827:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const __gnu_cxx::__normal_iterator<_Iterator, _Container>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/algorithm:61,
from project/update.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:820:5: note: candidate: template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)
operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
^
/usr/include/c++/5/bits/stl_iterator.h:820:5: note: template argument deduction/substitution failed:
project/update.cpp:71:105: note: ‘std::_Rb_tree_const_iterator<long unsigned int>’ is not derived from ‘const __gnu_cxx::__normal_iterator<_IteratorL, _Container>’
urn !(find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) == recentlyProcessed.end());
^
user#computer:~/projectClient#
Here's the build command (it doesn't make a difference if i remove -Wall):
g++ -O3 -Wall -Wno-deprecated-declarations -Wno-unused-variable -Wno-format-contains-nul -std=c++11 -D${JSON} \
-lpthread -lboost_system -lboost_chrono -lssl -lcrypto -ljsoncpp \
-o bin/client client.cpp common.cpp update.cpp
While the error spew is daunting at initial glance, it can be helpful in tricky cases. Just start at the top and work your way down until you figure out what the problem is.
In this case it looks like you're trying to compare a std::_Rb_tree_const_iterator<long unsigned int> with a std::_Rb_tree_iterator<std::pair<const IntervalTime, std::set<long unsigned int> > > which are iterators to completely different types of objects.
It seems that find(recentlyProcessed[it].begin(), recentlyProcessed[it].end(), id) returns an interator to a different container than what recentlyProcessed.end is - note that recentlyProcessed.end doesn't have an index.
Probably you need to compare with recentlyProcessed[it].end or recentlyProcessed[it].end() instead.

Error while copying one vector to other c++

I have overloaded allocator for most of the stl containers below is the code. The code is from here
#include <iostream>
#include <vector>
#include <list>
namespace outside
{
template<typename T>
struct MyAllocator
{
typedef typename std::allocator<T>::value_type value_type;
typedef typename std::allocator<T>::pointer pointer;
typedef typename std::allocator<T>::const_pointer const_pointer;
typedef typename std::allocator<T>::reference reference;
typedef typename std::allocator<T>::const_reference const_reference;
typedef typename std::allocator<T>::size_type size_type;
pointer allocate (size_type n, typename std::allocator<void>::const_pointer hint=0)
{
std::cerr << "allocate..." << std::endl;
return std::allocator<T>{}.allocate(n, hint);
}
void deallocate (pointer p, size_type n)
{
std::cerr << "deallocate..." << std::endl;
return std::allocator<T>{}.deallocate(p, n);
}
template <class Type> struct rebind
{
typedef MyAllocator<Type> other;
};
MyAllocator()
{
}
MyAllocator(const MyAllocator<T>& other )
{
}
template< class U >
MyAllocator( const MyAllocator<U>& other )
{
}
};
} // namespace outside
namespace outer
{
template<class T>
using vector = ::std::vector<T, outside::MyAllocator<T>>;
template<class T>
using list = ::std::list<T, outside::MyAllocator<T>>;
}
int main()
{
outer::vector<int> myVector1;
outer::vector<int> myVector2;
myVector1.push_back(10);
myVector1.push_back(20);
// myVector2 = myVector1; // Getting compilation error
for (auto i = myVector1.begin(); i != myVector1.end(); ++i) {
std::cout << *i << ' ';
}
std::list<int> myList1;
std::list<int> myList2;
myList2 = myList1; // // No compilation error
}
Copying one vector to another vector is giving me error. While for the same code copying one list to another list is working fine.
Compilation error
included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc: In instantiation of 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = outside::MyAllocator<int>]':
prog.cpp:59:15: required from here
/usr/include/c++/5/bits/vector.tcc:176:37: error: no match for 'operator!=' (operand types are 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' and 'const _Tp_alloc_type {aka const outside::MyAllocator<int>}')
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/iosfwd:40:0,
from /usr/include/c++/5/ios:38,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/postypes.h:221:5: note: candidate: template<class _StateT> bool std::operator!=(const std::fpos<_StateT>&, const std::fpos<_StateT>&)
operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
^
/usr/include/c++/5/bits/postypes.h:221:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::fpos<_StateT>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:227:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
/usr/include/c++/5/bits/stl_pair.h:227:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::pair<_T1, _T2>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:304:5: note: candidate: template<class _Iterator> bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator!=(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:304:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::reverse_iterator<_Iterator>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:354:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator!=(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:354:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::reverse_iterator<_Iterator>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:1077:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator!=(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
operator!=(const move_iterator<_IteratorL>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:1077:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::move_iterator<_Iterator>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:67:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_iterator.h:1083:5: note: candidate: template<class _Iterator> bool std::operator!=(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
operator!=(const move_iterator<_Iterator>& __x,
^
/usr/include/c++/5/bits/stl_iterator.h:1083:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::move_iterator<_Iterator>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:41:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/allocator.h:140:5: note: candidate: template<class _T1, class _T2> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_T2>&)
operator!=(const allocator<_T1>&, const allocator<_T2>&)
^
/usr/include/c++/5/bits/allocator.h:140:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::allocator<_CharT>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:41:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/allocator.h:146:5: note: candidate: template<class _Tp> bool std::operator!=(const std::allocator<_CharT>&, const std::allocator<_CharT>&)
operator!=(const allocator<_Tp>&, const allocator<_Tp>&)
^
/usr/include/c++/5/bits/allocator.h:146:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::allocator<_CharT>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:52:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4948:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/5/bits/basic_string.h:4948:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:52:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4960:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator!=(const _CharT* __lhs,
^
/usr/include/c++/5/bits/basic_string.h:4960:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: mismatched types 'const _CharT*' and 'outside::MyAllocator<int>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/string:52:0,
from /usr/include/c++/5/bits/locale_classes.h:40,
from /usr/include/c++/5/bits/ios_base.h:41,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:4972:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/5/bits/basic_string.h:4972:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/bits/ios_base.h:46:0,
from /usr/include/c++/5/ios:42,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/system_error:311:3: note: candidate: bool std::operator!=(const std::error_code&, const std::error_code&)
operator!=(const error_code& __lhs, const error_code& __rhs) noexcept
^
/usr/include/c++/5/system_error:311:3: note: no known conversion for argument 1 from 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' to 'const std::error_code&'
/usr/include/c++/5/system_error:315:3: note: candidate: bool std::operator!=(const std::error_code&, const std::error_condition&)
operator!=(const error_code& __lhs, const error_condition& __rhs) noexcept
^
/usr/include/c++/5/system_error:315:3: note: no known conversion for argument 1 from 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' to 'const std::error_code&'
/usr/include/c++/5/system_error:319:3: note: candidate: bool std::operator!=(const std::error_condition&, const std::error_code&)
operator!=(const error_condition& __lhs, const error_code& __rhs) noexcept
^
/usr/include/c++/5/system_error:319:3: note: no known conversion for argument 1 from 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' to 'const std::error_condition&'
/usr/include/c++/5/system_error:323:3: note: candidate: bool std::operator!=(const std::error_condition&, const std::error_condition&)
operator!=(const error_condition& __lhs,
^
/usr/include/c++/5/system_error:323:3: note: no known conversion for argument 1 from 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' to 'const std::error_condition&'
In file included from /usr/include/c++/5/bits/locale_facets.h:48:0,
from /usr/include/c++/5/bits/basic_ios.h:37,
from /usr/include/c++/5/ios:44,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/streambuf_iterator.h:210:5: note: candidate: template<class _CharT, class _Traits> bool std::operator!=(const std::istreambuf_iterator<_CharT, _Traits>&, const std::istreambuf_iterator<_CharT, _Traits>&)
operator!=(const istreambuf_iterator<_CharT, _Traits>& __a,
^
/usr/include/c++/5/bits/streambuf_iterator.h:210:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/vector:64:0,
from prog.cpp:2:
/usr/include/c++/5/bits/stl_vector.h:1535:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
^
/usr/include/c++/5/bits/stl_vector.h:1535:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::vector<_Tp, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/list:63:0,
from prog.cpp:3:
/usr/include/c++/5/bits/stl_list.h:291:5: note: candidate: template<class _Val> bool std::operator!=(const std::_List_iterator<_Tp>&, const std::_List_const_iterator<_Val>&)
operator!=(const _List_iterator<_Val>& __x,
^
/usr/include/c++/5/bits/stl_list.h:291:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::_List_iterator<_Tp>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
In file included from /usr/include/c++/5/list:63:0,
from prog.cpp:3:
/usr/include/c++/5/bits/stl_list.h:1843:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::list<_Tp, _Alloc>&, const std::list<_Tp, _Alloc>&)
operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
^
/usr/include/c++/5/bits/stl_list.h:1843:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/5/vector:69:0,
from prog.cpp:2:
/usr/include/c++/5/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::list<_Tp, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
I am trying to understand why this is the case and solution for this problem ?
The key part of the exception is hundreds of lines into it:
In file included from /usr/local/include/c++/5.2.0/vector:64:0,
from main.cpp:2: /usr/local/include/c++/5.2.0/bits/stl_vector.h:1535:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator!=(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
^
/usr/local/include/c++/5.2.0/bits/stl_vector.h:1535:5: note: template argument deduction/substitution failed:
In file included from /usr/local/include/c++/5.2.0/vector:69:0,
from main.cpp:2:
/usr/local/include/c++/5.2.0/bits/vector.tcc:176:37: note: 'std::_Vector_base<int, outside::MyAllocator<int> >::_Tp_alloc_type {aka outside::MyAllocator<int>}' is not derived from 'const std::vector<_Tp, _Alloc>'
&& _M_get_Tp_allocator() != __x._M_get_Tp_allocator())
^
vector::operator= requires vector::operator!=, which requires allocator::operator!=, which doesn't exist. Without it, the function can't be created. Simply add an operator!= to your allocator. While you're at it, also make sure you have all the other required allocator functions. If memory serves me right, you're missing a fair number.
Change the definition to struct MyAllocator: public std::allocator<T> and the code will compile.

c++ map creation and allocation in a class member

I am transferring something from another language to C++, as a complete beginner to C++ and I am trying to learn some essentials around struct creation and use in maps. I have this sketched below:
struct Cubic {
int X, Y, Z;
Cubic Neighbor(int);
};
struct Space{
Cubic location;
bool open;
bool blocked;
};
class Table {
int bound;
Cubic center;
std::map<Cubic, Space> grid;
Table* New(int, Cubic);
};
std::map<Cubic, Space> Allocate(int bound, Cubic center)
{
std::map<Cubic, Space> ret;
for (int x = -bound; x <= bound; x++) {
for (int y = std::max(-bound, -x-bound); y <= std::min(bound, -x+bound); y++) {
int z = -x - y;
Cubic cb = CubicAdd(center, {x, y, z});
ret[cb] = {location: cb, open: true}; //THIS IS A HUGE ERROR, see below
};
};
return ret;
}
It is basically a table cubic coordinates for hexagons. The other code can be posted, but it is not relevant to the matter at hand; i.e. it works in there and I have no problems understanding that, the issue is in trying to get to an understanding of basic C++ coding, which here is a map of Cubic structs keys to Space pointers embedded in a class Table....which I have not even gotten to instantiating yet.
Error:
doing
c++ table.cc -std=c++0x (for 2 files I have table.h & table.cc) generates this:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h: In instantiation of ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Cubic]’:
/usr/include/c++/4.8/bits/stl_map.h:463:31: required from ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = Cubic; _Tp = Space; _Compare = std::less<Cubic>; _Alloc = std::allocator<std::pair<const Cubic, Space> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = Space; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = Cubic]’
table.cc:63:13: required from here
/usr/include/c++/4.8/bits/stl_function.h:235:20: error: no match for ‘operator<’ (operand types are ‘const Cubic’ and ‘const Cubic’)
{ return __x < __y; }
^
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: candidates are:
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0,
from /usr/include/c++/4.8/bits/stl_tree.h:61,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_pair.h:220:5: note: template<class _T1, class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
/usr/include/c++/4.8/bits/stl_pair.h:220:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::pair<_T1, _T2>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/stl_tree.h:61,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_iterator.h:297:5: note: template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator<(const reverse_iterator<_Iterator>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:297:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::reverse_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/stl_tree.h:61,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_iterator.h:347:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator<(const reverse_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:347:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::reverse_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/stl_tree.h:61,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1055:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
operator<(const move_iterator<_IteratorL>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:1055:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::move_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0,
from /usr/include/c++/4.8/bits/stl_tree.h:61,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_iterator.h:1061:5: note: template<class _Iterator> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
operator<(const move_iterator<_Iterator>& __x,
^
/usr/include/c++/4.8/bits/stl_iterator.h:1061:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::move_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/map:60:0,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_tree.h:917:5: note: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator<(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x,
^
/usr/include/c++/4.8/bits/stl_tree.h:917:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/stdexcept:39,
from /usr/include/c++/4.8/array:38,
from /usr/include/c++/4.8/tuple:39,
from /usr/include/c++/4.8/bits/stl_map.h:63,
from /usr/include/c++/4.8/map:61,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/basic_string.h:2569:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2569:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/stdexcept:39,
from /usr/include/c++/4.8/array:38,
from /usr/include/c++/4.8/tuple:39,
from /usr/include/c++/4.8/bits/stl_map.h:63,
from /usr/include/c++/4.8/map:61,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/basic_string.h:2581:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2581:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/string:52:0,
from /usr/include/c++/4.8/stdexcept:39,
from /usr/include/c++/4.8/array:38,
from /usr/include/c++/4.8/tuple:39,
from /usr/include/c++/4.8/bits/stl_map.h:63,
from /usr/include/c++/4.8/map:61,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/basic_string.h:2593:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const _CharT* __lhs,
^
/usr/include/c++/4.8/bits/basic_string.h:2593:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: mismatched types ‘const _CharT*’ and ‘Cubic’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/tuple:39:0,
from /usr/include/c++/4.8/bits/stl_map.h:63,
from /usr/include/c++/4.8/map:61,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/array:238:5: note: template<class _Tp, long unsigned int _Nm> bool std::operator<(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&)
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
^
/usr/include/c++/4.8/array:238:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::array<_Tp, _Nm>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/bits/stl_map.h:63:0,
from /usr/include/c++/4.8/map:61,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/tuple:824:5: note: template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const std::tuple<_Args1 ...>&, const std::tuple<_Args2 ...>&)
operator<(const tuple<_TElements...>& __t,
^
/usr/include/c++/4.8/tuple:824:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::tuple<_Args1 ...>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/map:61:0,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_map.h:979:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)
operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
^
/usr/include/c++/4.8/bits/stl_map.h:979:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::map<_Key, _Tp, _Compare, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/include/c++/4.8/map:62:0,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_multimap.h:881:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
^
/usr/include/c++/4.8/bits/stl_multimap.h:881:5: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/bits/stl_tree.h:63:0,
from /usr/include/c++/4.8/map:60,
from table.h:3,
from table.cc:1:
/usr/include/c++/4.8/bits/stl_function.h:235:20: note: ‘const Cubic’ is not derived from ‘const std::multimap<_Key, _Tp, _Compare, _Alloc>’
{ return __x < __y; }
^
You didn't post a definition of Cubic, but the issue is from the first error:
/usr/include/c++/4.8/bits/stl_function.h: In instantiation of ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Cubic]’:
/usr/include/c++/4.8/bits/stl_map.h:463:31: required from ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = Cubic; _Tp = Space; _Compare = std::less<Cubic>; _Alloc = std::allocator<std::pair<const Cubic, Space> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = Space; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = Cubic]’
table.cc:63:13: required from here
/usr/include/c++/4.8/bits/stl_function.h:235:20: error: no match for ‘operator<’ (operand types are ‘const Cubic’ and ‘const Cubic’)
{ return __x < __y; }
^
std::map is a binary tree (red-black tree specifically) and it needs its keys to be LessThanComparable. By default, this uses operator< and your Key (Cubic) does not have a member or non-member operator< defined. The rest of the compile error is the compiler trying to stick Cubic into all the other operator<'s that it can find for any other type - none of which apply since Cubic isn't convertible to any of those.
So either provide one:
bool operator<(const Cubic& a, const Cubic& b) {
// something reasonable, probably like
return std::tie(a.X, a.Y, a.Z) < std::tie(b.X, b.Y, b.Z);
}
Or provide your map with a custom comparator:
struct CubicCompare {
bool operator()(const Cubic& a, const Cubic& b) const {
// something reasonable, return true if a is "less than" b
}
};
std::map<Cubic, Space, CubicCompare> ret;
std::map<> needs comparison operators to sort and order its data. By default, it uses the < operator. Looking at your errors, it looks like such an operator is not implemented in your Cubic class. You can solve this problem by overloading < in your Cubic class or use a custom comparator.
Heres info for a custom comparator.
Heres info for operator overloading.

Issues with Declaring a C++ Priority Queue using a custom Comparator

I have been trying to implement a Priority queue consisting of a custom data type and a custom comparator but when I try to compile I get this error. I have tried multiple declarations but they all yield this error.
priority_queue<myData, vector<myData>, myComp> myPQ;
priority_queue<myData, vector<myData>, myComp> myPQ(compVariable);
I also am trying to create a vector of these priority queues after creating them.
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h: In instantiation of ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Order]’:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_heap.h:183:47: required from ‘void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Order*, std::vector<Order, std::allocator<Order> > >; _Distance = long int; _Tp = Order; _Compare = std::less<Order>]’
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_heap.h:222:58: required from ‘void std::push_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Order*, std::vector<Order, std::allocator<Order> > >; _Compare = std::less<Order>]’
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_queue.h:499:41: required from ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = Order; _Sequence = std::vector<Order, std::allocator<Order> >; _Compare = std::less<Order>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = Order]’
Market.cpp:144:32: required from here
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: error: no match for ‘operator<’ (operand types are ‘const Order’ and ‘const Order’)
{ return __x < __y; }
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: candidates are:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_algobase.h:64:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/char_traits.h:39,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_pair.h:220:5: note: template<class _T1, class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_pair.h:220:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::pair<_T1, _T2>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_algobase.h:67:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/char_traits.h:39,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_iterator.h:297:5: note: template<class _Iterator> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
operator<(const reverse_iterator<_Iterator>& __x,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_iterator.h:297:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::reverse_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_algobase.h:67:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/char_traits.h:39,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_iterator.h:347:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&)
operator<(const reverse_iterator<_IteratorL>& __x,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_iterator.h:347:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::reverse_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_algobase.h:67:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/char_traits.h:39,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_iterator.h:1055:5: note: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&)
operator<(const move_iterator<_IteratorL>& __x,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_iterator.h:1055:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::move_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_algobase.h:67:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/char_traits.h:39,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_iterator.h:1061:5: note: template<class _Iterator> bool std::operator<(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
operator<(const move_iterator<_Iterator>& __x,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_iterator.h:1061:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::move_iterator<_Iterator>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:52:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/basic_string.h:2569:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/basic_string.h:2569:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:52:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/basic_string.h:2581:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/basic_string.h:2581:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::basic_string<_CharT, _Traits, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:52:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/basic_string.h:2593:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
operator<(const _CharT* __lhs,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/basic_string.h:2593:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: mismatched types ‘const _CharT*’ and ‘Order’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/vector:64:0,
from P2.h:4,
from Market.cpp:3:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_vector.h:1420:5: note: template<class _Tp, class _Alloc> bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_vector.h:1420:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::vector<_Tp, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/deque:64:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/queue:60,
from Market.cpp:6:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_deque.h:273:5: note: template<class _Tp, class _Ref, class _Ptr> bool std::operator<(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&)
operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_deque.h:273:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::_Deque_iterator<_Tp, _Ref, _Ptr>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/deque:64:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/queue:60,
from Market.cpp:6:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_deque.h:281:5: note: template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> bool std::operator<(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&)
operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_deque.h:281:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::_Deque_iterator<_Tp, _Ref, _Ptr>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/deque:64:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/queue:60,
from Market.cpp:6:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_deque.h:1975:5: note: template<class _Tp, class _Alloc> bool std::operator<(const std::deque<_Tp, _Alloc>&, const std::deque<_Tp, _Alloc>&)
operator<(const deque<_Tp, _Alloc>& __x,
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_deque.h:1975:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::deque<_Tp, _Alloc>’
{ return __x < __y; }
^
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/queue:64:0,
from Market.cpp:6:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_queue.h:286:5: note: template<class _Tp, class _Seq> bool std::operator<(const std::queue<_Tp, _Seq>&, const std::queue<_Tp, _Seq>&)
operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
^
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_queue.h:286:5: note: template argument deduction/substitution failed:
In file included from /usr/um/gcc-4.8.2/include/c++/4.8.2/string:48:0,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/locale_classes.h:40,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/bits/ios_base.h:41,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ios:42,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/ostream:38,
from /usr/um/gcc-4.8.2/include/c++/4.8.2/iostream:39,
from Market.cpp:1:
/usr/um/gcc-4.8.2/include/c++/4.8.2/bits/stl_function.h:235:20: note: ‘const Order’ is not derived from ‘const std::queue<_Tp, _Seq>’
{ return __x < __y; }
Here is an example of what is causing the error:
class myData {
public:
int a;
int b;
int c;
int d;
};
class myComp {
public:
bool operator()(myData& d1, myData& d2) {
if(d1.a == d2.a) {
return d2.b < d2.c;
}
else {
return d1.a < d2.a;
}
}
};
priority_queue<myData, vector<myData>, myComp> myPQ;
vector<priority_queue<myData, vector<myData>, myComp> > vec_PQ(n, myPQ);
From : http://en.cppreference.com/w/cpp/concept/Compare
The concept Compare is a set of requirements expected by some of the standard library facilities from the user-provided function object types.
The return value of the function call operation applied to an object of type Compare, when contextually converted to bool, yields true if the first argument of the call appears before the second in the strict weak ordering relation induced by this Compare type, and false otherwise.
As with any BinaryPredicate, evaluation of that expression is not allowed to call non-const member functions of the dereferenced iterators.
The arguments to myComp::operator() should be const&.
bool myComp::operator()(myData const& d1, myData const& d2) {
As indicated by #T.C. in a comment, the function itself should be a const member function but that is strictly not necessary in this case.