Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-11-22 03:39:58


Hi everyone,

I've tried compiling the following code and I get a weird error
message with std::getline -- so I don't know if the problem is with
asio, or with Microsoft's STL implementation.

#include <boost/asio.hpp>
#include <iostream>
#include <string>

using namespace std;
using namespace boost;

int main(int argc, char * argv[]) {
    using asio::ip::tcp::iostream;
    iostream http_stream("www.boost.org", "http");
    http_stream
        << L"GET / HTTP/1.0\r\n"
        << L"Host: www.boost.org\r\n"
        << L"\r\n"
        << std::flush
        ;

    std::wostringstream http_response_stream;
    std::wstring line;
    while (!http_stream) {
        std::getline(http_stream, line, L'\n');
        std::wcout << line << std::endl;
    };

    return EXIT_SUCCESS;
};

The build output is as follows:

1>main.cpp(52) : error C2784: 'std::basic_istream<_Elem,_Traits>
&std::getline(std::basic_istream<_Elem,_Traits>
&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
template argument for 'std::basic_istream<_Elem,_Traits> &' from
'boost::asio::ip::tcp::iostream'
1> C:\Program Files\Microsoft Visual Studio
8\VC\INCLUDE\string(528) : see declaration of 'std::getline'
1>main.cpp(52) : error C2784: 'std::basic_istream<_Elem,_Traits>
&std::getline(std::basic_istream<_Elem,_Traits>
&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
template argument for 'std::basic_istream<_Elem,_Traits> &' from
'boost::asio::ip::tcp::iostream'
1> C:\Program Files\Microsoft Visual Studio
8\VC\INCLUDE\string(528) : see declaration of 'std::getline'
1>main.cpp(52) : error C2784: 'std::basic_istream<_Elem,_Traits>
&std::getline(std::basic_istream<_Elem,_Traits>
&,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce
template argument for 'std::basic_istream<_Elem,_Traits> &' from
'boost::asio::ip::tcp::iostream'
1> C:\Program Files\Microsoft Visual Studio
8\VC\INCLUDE\string(528) : see declaration of 'std::getline'
1>Building Boost.Regex with the optional Unicode/ICU support disabled.
1>Please refer to the Boost.Regex documentation for more information
1>main.cpp(52) : error C2782: 'std::basic_istream<_Elem,_Traits>
&std::getline(std::basic_istream<_Elem,_Traits>
&,std::basic_string<_Elem,_Traits,_Alloc> &)' : template parameter
'_Elem' is ambiguous
1>(don't panic: this is a strictly optional feature).
1> C:\Program Files\Microsoft Visual Studio
8\VC\INCLUDE\string(528) : see declaration of 'std::getline'
1> could be 'wchar_t'
1> or 'char'
1>main.cpp(52) : error C2780: 'std::basic_istream<_Elem,_Traits>
&std::getline(std::basic_istream<_Elem,_Traits>
&,std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem)' : expects 3
arguments - 2 provided

I'm using MSVC 8.0 with an updated boost trunk.

Pointers would be most appreciated.

-- 
Dean Michael C. Berris
Software Engineer, Friendster, Inc.
[http://cplusplus-soup.blogspot.com/]
[mikhailberis_at_[hidden]]
[+63 928 7291459]
[+1 408 4049523]

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk