-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Description
The following program does not compile (https://wandbox.org/permlink/odsAUNRroBveTxqw). (I tested clang 8.0.0
and g++ 9.1.0
.)
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/key.hpp>
struct S final {
int m_n;
S(int n) noexcept : m_n(n) {}
int Get() const & noexcept { // removing "& noexcept" makes it compile
return m_n;
}
};
int main() {
boost::multi_index::multi_index_container<
S,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::key<&S::Get>
>
>
> container;
}
clang 8.0.0
reports:
In file included from prog.cc:3:
/opt/wandbox/boost-1.70.0/clang-8.0.0/include/boost/multi_index/key.hpp:77:22: error: implicit instantiation of undefined template 'boost::multi_index::detail::typed_key_impl<int (S::*)() const & noexcept, &S::Get, void>'
struct key_impl<Key>:typed_key_impl<decltype(Key),Key>{};
^
/opt/wandbox/boost-1.70.0/clang-8.0.0/include/boost/multi_index/key.hpp:134:23: note: in instantiation of template class 'boost::multi_index::detail::key_impl<&S::Get>' requested here
using type=typename key_impl<Keys...>::type;
^
/opt/wandbox/boost-1.70.0/clang-8.0.0/include/boost/multi_index/key.hpp:140:1: note: in instantiation of template class 'boost::multi_index::detail::limited_size_key_impl<&S::Get>' requested here
using key=typename detail::limited_size_key_impl<Keys...>::type;
^
prog.cc:18:37: note: in instantiation of template type alias 'key' requested here
boost::multi_index::key<&S::Get>
^
/opt/wandbox/boost-1.70.0/clang-8.0.0/include/boost/multi_index/key.hpp:38:8: note: template is declared here
struct typed_key_impl;
^
prog.cc:20:9: error: expected a type
>
^
prog.cc:21:5: error: expected a type
> container;
^
prog.cc:21:7: error: C++ requires a type specifier for all declarations
> container;
^
4 errors generated.
I suspect that the problem is that key_impl
is not specialized for const&
and/or noexcept
member functions.
Metadata
Metadata
Assignees
Labels
No labels