하루 종일 Boost :: Signals2 라이브러리를 사용하여 코드 부분에서 컴파일러 오류가 발생했습니다. 나는 최소한의 예에 할 노력하고있어 감소했습니다clang은 boost :: signals2를 좋아하지 않습니까?
#include <boost/signals2.hpp>
int foo();
struct first_nonzero
{
using result_type = int;
template <typename It>
result_type operator()(It first, It last) const
{
while(first != last)
{
if(*first != 0)
{
return *first;
}
}
return 0;
}
};
int foo()
{
using signal = boost::signals2::signal<int(), first_nonzero>;
signal s;
return s();
}
내가 템플릿 공제 오류가 겉으로 신호 라이브러리에서 오는 얻을
clang -o foo.o -c foo.cpp -std=c++11 -Weverything -Wno-c++98-compat
로이 코드를 컴파일하려고 자체 :
In file included from foo.cpp:1:
In file included from /usr/include/boost/signals2.hpp:19:
In file included from /usr/include/boost/signals2/signal.hpp:38:
In file included from /usr/include/boost/signals2/variadic_signal.hpp:21:
/usr/include/boost/signals2/detail/variadic_slot_invoker.hpp:84:23: error: no matching function for call to 'get'
return func(std::get<indices>(args)...);
^~~~~~~~~~~~~~~~~
/usr/include/boost/signals2/detail/variadic_slot_invoker.hpp:78:18: note: in instantiation of function template specialization 'boost::signals2::detail::call_with_tuple_args<int>::m_invoke<int,
boost::function<int()>, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>' requested here
return m_invoke(resolver, func, indices_type(), args);
^
/usr/include/boost/signals2/detail/variadic_slot_invoker.hpp:120:18: note: in instantiation of function template specialization 'boost::signals2::detail::call_with_tuple_args<int>::operator()<boost::function<int
()>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>' requested here
return call_with_tuple_args<result_type>()(connectionBody->slot.slot_function(), _args);
^
/usr/include/boost/signals2/detail/variadic_slot_invoker.hpp:106:18: note: in instantiation of function template specialization 'boost::signals2::detail::variadic_slot_invoker<int,
>::m_invoke<boost::shared_ptr<boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int()> >,
boost::signals2::mutex> > >' requested here
return m_invoke(connectionBody,
^
/usr/include/boost/signals2/detail/slot_call_iterator.hpp:82:35: note: in instantiation of function template specialization 'boost::signals2::detail::variadic_slot_invoker<int,
>::operator()<boost::shared_ptr<boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int()> >,
boost::signals2::mutex> > >' requested here
cache->result.reset(cache->f(*iter));
^
/usr/include/boost/iterator/iterator_facade.hpp:514:20: note: in instantiation of member function 'boost::signals2::detail::slot_call_iterator_t<boost::signals2::detail::variadic_slot_invoker<int, >,
std::_List_iterator<boost::shared_ptr<boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int
()> >, boost::signals2::mutex> > >, boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int()>
>, boost::signals2::mutex> >::dereference' requested here
return f.dereference();
^
/usr/include/boost/iterator/iterator_facade.hpp:639:18: note: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 to see all)
return iterator_core_access::dereference(this->derived());
^
foo.cpp:14:16: note: in instantiation of member function 'boost::iterator_facade<boost::signals2::detail::slot_call_iterator_t<boost::signals2::detail::variadic_slot_invoker<int, >,
std::_List_iterator<boost::shared_ptr<boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int
()> >, boost::signals2::mutex> > >, boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int()>
>, boost::signals2::mutex> >, int, boost::single_pass_traversal_tag, const int &, long>::operator*' requested here
if(*first != 0)
^
/usr/include/boost/signals2/detail/result_type_wrapper.hpp:53:18: note: in instantiation of function template specialization
'first_nonzero::operator()<boost::signals2::detail::slot_call_iterator_t<boost::signals2::detail::variadic_slot_invoker<int, >,
std::_List_iterator<boost::shared_ptr<boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int
()> >, boost::signals2::mutex> > >, boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int()>
>, boost::signals2::mutex> > >' requested here
return combiner(first, last);
^
/usr/include/boost/signals2/detail/signal_template.hpp:241:18: note: in instantiation of function template specialization 'boost::signals2::detail::combiner_invoker<int>::operator()<first_nonzero,
boost::signals2::detail::slot_call_iterator_t<boost::signals2::detail::variadic_slot_invoker<int, >,
std::_List_iterator<boost::shared_ptr<boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int
()> >, boost::signals2::mutex> > >, boost::signals2::detail::connection_body<std::pair<boost::signals2::detail::slot_meta_group, boost::optional<int> >, boost::signals2::slot<int(), boost::function<int()>
>, boost::signals2::mutex> > >' requested here
return detail::combiner_invoker<typename combiner_type::result_type>()
^
/usr/include/boost/signals2/detail/signal_template.hpp:695:16: note: in instantiation of member function 'boost::signals2::detail::signal_impl<int(), first_nonzero, int, std::less<int>, boost::function<int()>,
boost::function<int (const boost::signals2::connection &)>, boost::signals2::mutex>::operator()' requested here
return (*_pimpl)(BOOST_SIGNALS2_SIGNATURE_ARG_NAMES(BOOST_SIGNALS2_NUM_ARGS));
^
foo.cpp:27:13: note: in instantiation of member function 'boost::signals2::signal<int(), first_nonzero, int, std::less<int>, boost::function<int()>, boost::function<int (const boost::signals2::connection &)>,
boost::signals2::mutex>::operator()' requested here
return s();
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/utility:141:5: note: candidate template ignored: failed template argument deduction
get(std::pair<_Tp1, _Tp2>& __in) noexcept
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/utility:146:5: note: candidate template ignored: failed template argument deduction
get(std::pair<_Tp1, _Tp2>&& __in) noexcept
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/utility:151:5: note: candidate template ignored: failed template argument deduction
get(const std::pair<_Tp1, _Tp2>& __in) noexcept
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/array:267:5: note: candidate template ignored: failed template argument deduction
get(array<_Tp, _Nm>& __arr) noexcept
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/array:276:5: note: candidate template ignored: failed template argument deduction
get(array<_Tp, _Nm>&& __arr) noexcept
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/array:284:5: note: candidate template ignored: failed template argument deduction
get(const array<_Tp, _Nm>& __arr) noexcept
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/tuple:756:5: note: candidate template ignored: failed template argument deduction
get(tuple<_Elements...>& __t) noexcept
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/tuple:763:5: note: candidate template ignored: failed template argument deduction
get(const tuple<_Elements...>& __t) noexcept
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/tuple:770:5: note: candidate template ignored: failed template argument deduction
get(tuple<_Elements...>&& __t) noexcept
^
1 error generated.
후 나는 다른 컴파일러를 시도 미친 생각에 포기하기로 결정하고, 놀랍게도 내가
와 같은 조각을 컴파일하는 경우 약간의 시간g++ -o foo.o -c foo.cpp -std=c++11 -Wall -Wextra -pedantic
오류가 없습니다. 나는 Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM 3.2)
과 g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
을 실행 중입니다. 부스트 라이브러리 1.54.
프로젝트 제한으로 인해 다른 컴파일러를 사용할 수 없습니다. clang에 충실하면서 boost :: signals2 라이브러리를 사용할 수있는 방법이 있습니까?
[잘 작동하는 coliru] (http://coliru.stacked-crooked.com/a/51fcdc08d0fd1be4) – dyp