這段代碼沒有辦法乾淨地編譯。對於需要字符串參數的函數,您不能綁定float。錯誤spewage的例子,我得到,如果我試着和升壓編譯代碼1.34.1 & G ++ 4.1.2:
include/boost-1_34_1/boost/bind.hpp: In member function 'R
boost::_bi::list1<A1>::operator()(boost::_bi::type<R>, F&, A&, long
int) [with R = double, F = double (*)(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >), A =
boost::_bi::list0, A1 = boost::_bi::value<float>]':
include/boost-1_34_1/boost/bind/bind_template.hpp:20: instantiated
from 'typename boost::_bi::result_traits<R, F>::type
boost::_bi::bind_t<R, F, L>::operator()() [with R = double, F = double
(*)(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >), L =
boost::_bi::list1<boost::_bi::value<float> >]'
boost-1_34_1/boost/function/function_template.hpp:158: instantiated
from 'static void
boost::detail::function::void_function_obj_invoker0<FunctionObj,
R>::invoke(boost::detail::function::function_buffer&) [with
FunctionObj = boost::_bi::bind_t<double, double
(*)(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >), boost::_bi::list1<boost::_bi::value<float> >
>, R = void]'
include/boost-1_34_1/boost/function/function_template.hpp:787:
instantiated from 'void boost::function0<R,
Allocator>::assign_to(const Functor&) [with Functor =
boost::_bi::bind_t<double, double (*)(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >),
boost::_bi::list1<boost::_bi::value<float> > >, R = void, Allocator =
std::allocator<void>]'
include/boost-1_34_1/boost/function/function_template.hpp:624:
instantiated from 'boost::function0<R, Allocator>::function0(Functor,
typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = boost::_bi::bind_t<double, double
(*)(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >), boost::_bi::list1<boost::_bi::value<float> >
>, R = void, Allocator = std::allocator<void>]'
include/boost-1_34_1/boost/function/function_template.hpp:886:
instantiated from 'boost::function<R()(),
Allocator>::function(Functor, typename
boost::enable_if_c<boost::type_traits::ice_not<boost::is_integral<Functor>::value>::value,
int>::type) [with Functor = boost::_bi::bind_t<double, double
(*)(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >), boost::_bi::list1<boost::_bi::value<float> >
>, R = void, Allocator = std::allocator<void>]'
testbind.cpp:18: instantiated from here
include/boost-1_34_1/boost/bind.hpp:221: error: conversion from
'float' to non-scalar type 'std::basic_string<char,
std::char_traits<char>, std::allocator<char> >' requested
你爲什麼使用這樣一箇舊版本的Boost? –
你應該使用一個足夠強大的Boost版本,它的'function'實現可以處理這些。 –
如果更高版本解決了這個問題,我可能會轉向更新的版本。 – user1073072