Boost binding a function taking a reference

Posted by Jamie Cook on Stack Overflow See other posts from Stack Overflow or by Jamie Cook
Published on 2010-04-26T09:43:51Z Indexed on 2010/04/26 10:03 UTC
Read the original article Hit count: 257

Filed under:
|
|
|
|

Hi all,

I am having problems compiling the following snippet

int temp; 
vector<int> origins;

vector<string> originTokens = OTUtils::tokenize(buffer, ","); // buffer is a char[] array

// original loop 
BOOST_FOREACH(string s, originTokens)
{
    from_string(temp, s);
    origins.push_back(temp);
}    

// I'd like to use this to replace the above loop
std::transform(originTokens.begin(), originTokens.end(), origins.begin(), boost::bind<int>(&FromString<int>, boost::ref(temp), _1));

where the function in question is

// the third parameter should be one of std::hex, std::dec or std::oct
template <class T>
bool FromString(T& t, const std::string& s, std::ios_base& (*f)(std::ios_base&) = std::dec)
{
    std::istringstream iss(s);
    return !(iss >> f >> t).fail();
}

the error I get is

1>Compiling with Intel(R) C++ 11.0.074 [IA-32]... (Intel C++ Environment)
1>C:\projects\svn\bdk\Source\deps\boost_1_42_0\boost/bind/bind.hpp(303): internal error: assertion failed: copy_default_arg_expr: rout NULL, no error (shared/edgcpfe/il.c, line 13919)
1>
1>          return unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
1>                                                                                ^
1>
1>icl: error #10298: problem during post processing of parallel object compilation

Google is being unusually unhelpful so I hope that some one here can provide some insights.

© Stack Overflow or respective owner

Related posts about c++

Related posts about intel