Boost::lambda - Beispiel aus Buch funktioniert nicht



  • Hallo,

    probiere gerade einige Beispiele aus dem Buch "Beyond the C++ Standard Library" aus.

    Bei einem Beispiel aus Kapitel 10 - boost::lambda kommt es zu Fehlermeldungen

    habe das Beispiel verinfacht, so dass der Fehler noch auftritt:

    #include <iostream>
    #include <boost/function.hpp>
    #include <boost/lambda/lambda.hpp>
    
    int main()
    {
      using namespace boost::lambda;
    
      (std::cout << _1 << " " << _3 << " " << _2 << "!\n")("Hello", "friend", "my");
      return 0;
    }
    

    Es kommt dann zu folgender Fehlermeldung (Auszug)

    1>c:\test\lambda.cpp(16) : error C2914: 'boost::lambda::operator <<' : cannot deduce template argument as function argument is ambiguous
    1>c:\test\lambda.cpp(16) : error C2784: 'const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<Action>,boost::tuples::tuple<detail::convert_ostream_to_ref_others_to_c_plain_by_default<T>::type,boost::lambda::lambda_functor<Arg>>>> boost::lambda::operator <<(A &,const boost::lambda::lambda_functor<Arg> &)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
    1> with
    1> [
    1> Action=boost::lambda::leftshift_action
    1> ]
    1> d:\boost\boost_1_39_0\boost\lambda\detail\operators.hpp(205) : see declaration of 'boost::lambda::operator <<'
    1>c:\test\lambda.cpp(16) : error C2784: 'const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::bitwise_action<Action>,boost::tuples::tuple<detail::convert_ostream_to_ref_others_to_c_plain_by_default<T>::type,boost::lambda::lambda_functor<Arg>>>> boost::lambda::operator <<(A &,const boost::lambda::lambda_functor<Arg> &)' : could not deduce template argument for 'overloaded function type' from 'overloaded function type'
    1> with
    1> [
    1> Action=boost::lambda::leftshift_action
    1> ]
    1> d:\boost\boost_1_39_0\boost\lambda\detail\operators.hpp(205) : see declaration of 'boost::lambda::operator <<'

    Weiss jemand was da falsch läuft?

    Gruss Lars.


  • Mod

    Am Code ist nichts auszusetzen.



  • Mit Boost 1_37_1 und MinGW G++ 3.4.5 geht's schonmal. Ich bekomme die erwartete Ausgabe

    Hello my friend!
    

    Welche MSVC++ Version benutzt Du?


  • Mod

    VS2008+boost 1.40 macht auch keine Schwierigkeiten



  • Scheint boost 1.39 zu sein, jetzt stellt sich nur noch die Frage nach dem Compiler und ob dieser Compiler boost::lamba unterstützt (oder umgekehrt).


Anmelden zum Antworten