Boost logo

Boost Users :

Subject: [Boost-users] boost::xpressive Error 2668 call to amibous function
From: Jens Saathoff (jensesaat_at_[hidden])
Date: 2011-09-07 16:52:37


I get the error C2668 if i try to compile the following code(xpressive
example from docs):

#include <string>

#include <iostream>

#include <boost/xpressive/xpressive.hpp>

#include <boost/xpressive/regex_actions.hpp>

#include <map>

 using namespace boost::xpressive;

 int main()


        std::map<std::string, int> result;

        std::string str("aaa=>1 bbb=>23 ccc=>456");

         // Match a word and an integer, separated by =>,

        // and then stuff the result into a std::map<>

        sregex pair = ( (s1= +_w) >> "=>" >> (s2= +_d) )[ ref(result)[s1] =
as<int>(s2) ];

         // Match one or more word/integer pairs, separated

        // by whitespace.

        sregex rx = pair >> *(+_s >> pair);

         if(regex_match(str, rx))


                std::cout << result["aaa"] << '\n';

                std::cout << result["bbb"] << '\n';

                std::cout << result["ccc"] << '\n';


         return 0;


The complete error:

D:\Projekte\xpressive-test\main.cpp:29: Fehler:C2668:
'boost::xpressive::ref' : ambiguous call to overloaded function
could be 'const boost::xpressive::reference<T>
boost::xpressive::ref<std::map<_Kty,_Ty>>(T &)'
C:\Program Files (x86)\Microsoft Visual Studio
10.0\VC\INCLUDE\xrefwrap(439): or
std::tr1::ref<std::map<_Kty,int>>(_Ty &)' [found using
argument-dependent lookup]
while trying to match the argument list '(std::map<_Kty,_Ty>)'

What's the problem here?

Thank you very much!

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at