Hi,
I'm using a heap whose elements are value_type from a map; hence the key type is const. Some heaps seem to accept this gracefully, other just fail to compile. Is this expected? I saw no requirement about T in the documentation. This is Boost 1.59 from Mac Ports, on OS X.
$ cat foo.cc
#include <tuple>
#include <string>
#include
#include
int main()
{
using datum_t = std::tuple<const std::string>;
{
using queue_t = boost::heap::fibonacci_heap;
auto q = queue_t{};
q.emplace("foo");
}
{
using queue_t = boost::heap::priority_queue;
auto q = queue_t{};
q.emplace("foo");
}
}
$ clang++-mp-3.7 -std=c++11 /tmp/foo.cc -isystem /opt/local/include
In file included from /tmp/foo.cc:1:
/opt/local/libexec/llvm-3.7/bin/../include/c++/v1/tuple:283:19: error: no viable overloaded '='
value = _VSTD::forward<_Tp>(__t);
~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/libexec/llvm-3.7/bin/../include/c++/v1/tuple:485:45: note: in instantiation of function template specialization 'std::__1::__tuple_leaf<0, const
std::__1::basic_string<char>, false>::operator=' requested here
__swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...);
^
/opt/local/libexec/llvm-3.7/bin/../include/c++/v1/tuple:498:29: note: in instantiation of member function 'std::__1::__tuple_impl, const
std::__1::basic_string<char> >::operator=' requested here
class _LIBCPP_TYPE_VIS_ONLY tuple
^
/opt/local/libexec/llvm-3.7/bin/../include/c++/v1/algorithm:4848:5: note: in instantiation of function template specialization
'std::__1::__sift_up, std::__1::less
>, false, unsigned long, false> &, std::__1::__wrap_iter *> >' requested here
__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
^
/opt/local/include/boost/heap/priority_queue.hpp:261:14: note: in instantiation of function template specialization 'std::__1::push_heap *>, boost::heap::detail::heap_base, std::__1::less >, false, unsigned long, false> >' requested here
std::push_heap(q_.begin(), q_.end(), static_cast(*this));
^
/tmp/foo.cc:17:7: note: in instantiation of function template specialization 'boost::heap::priority_queue,
boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::emplace' requested here
q.emplace("foo");
^
/opt/local/libexec/llvm-3.7/bin/../include/c++/v1/string:1376:19: note: candidate function not viable: 'this' argument has type 'const std::__1::basic_string<char>', but method is
not marked const
basic_string& operator=(const basic_string& __str);
^
/opt/local/libexec/llvm-3.7/bin/../include/c++/v1/string:1379:19: note: candidate function not viable: 'this' argument has type 'const std::__1::basic_string<char>', but method is
not marked const
basic_string& operator=(basic_string&& __str)
^
/opt/local/libexec/llvm-3.7/bin/../include/c++/v1/string:1383:45: note: candidate function not viable: 'this' argument has type 'const std::__1::basic_string<char>', but method is
not marked const
_LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);}
^
/opt/local/libexec/llvm-3.7/bin/../include/c++/v1/string:1384:19: note: candidate function not viable: 'this' argument has type 'const std::__1::basic_string<char>', but method is
not marked const
basic_string& operator=(value_type __c);
^
/opt/local/libexec/llvm-3.7/bin/../include/c++/v1/string:1387:19: note: candidate function not viable: 'this' argument has type 'const std::__1::basic_string<char>', but method is
not marked const
basic_string& operator=(initializer_list __il) {return assign(__il.begin(), __il.size());}
^
1 error generated.
Thanks in advance.