Boost logo

Boost Users :

Subject: [Boost-users] Iostreams tag dispatch failure?
From: Stéphane Perras (sperras_at_[hidden])
Date: 2008-10-15 19:26:50


Hi all,
 
I've been trying to compile the container_source example from the boost/iostreams documentation for a couple of days actually without success. It seems to me that tag dispatching fails to dispatch the default (for any_tag) implementation for optimal_buffer_size( ), imbue( ) and flush( ). I'm using Visual C++ 2005 SP1. I saw one unanswered posting about this exact problem early 2007, but on GCC. So I guess from this that I'm missing something obvious.
 
Thanks for any help.
Steph.
 
Ps: code and build log following.
 
#include "stdafx.h"
#include <algorithm> // copy, min
#include <iosfwd> // streamsize
#include <boost/iostreams/categories.hpp> // source_tag
#include <boost/iostreams/stream.hpp>
#include <string>
template<typename Container>
class container_source;
template<typename Container>
class container_source {
public:
    typedef typename Container::value_type char_type;
    typedef boost::iostreams::source_tag category;
    container_source(Container& container)
        : container_(container), pos_(0)
    { }
    std::streamsize read(char_type* s, std::streamsize n)
    {
        using namespace std;
        streamsize amt = static_cast<streamsize>(container_.size() - pos_);
        streamsize result = (min)(n, amt);
        if (result != 0) {
            std::copy( container_.begin() + pos_,
                container_.begin() + pos_ + result,
                s );
            pos_ += result;
            return result;
        } else {
            return -1; // EOF
        }
    }
    Container& container() { return container_; }
private:
    typedef typename Container::size_type size_type;
    Container& container_;
    size_type pos_;
};
int main(int argc, char* argv[])
{
    using namespace std;
    typedef container_source<string> string_source;
    string input = "Hello World!\nThis is a test...\nShouldn't break\nthe assert";
    string output;
    boost::iostreams::stream<string_source> in(input);
    getline(in, output);
    assert(input == output);
    return 0;
}
 
Build log:
 
------ Build started: Project: tstIostreams, Configuration: Debug Win32 ------
Compiling...
tstIostreams.cpp
e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\optimal_buffer_size.hpp(39) : error C2039: 'optimal_buffer_size' : is not a member of 'boost::iostreams::detail::optimal_buffer_size_impl<T>'
        with
        [
            T=string_source
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(162) : see reference to function template instantiation 'std::streamsize boost::iostreams::optimal_buffer_size<T>(const T &)' being compiled
        with
        [
            T=string_source
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(155) : while compiling class template member function 'void boost::iostreams::detail::indirect_streambuf<T,Tr,Alloc,Mode>::open(const T &,int,int)'
        with
        [
            T=string_source,
            Tr=std::char_traits<char>,
            Alloc=std::allocator<char>,
            Mode=boost::iostreams::detail::io_mode_impl<1>::type
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(195) : while compiling class template member function 'bool boost::iostreams::detail::indirect_streambuf<T,Tr,Alloc,Mode>::is_open(void) const'
        with
        [
            T=string_source,
            Tr=std::char_traits<char>,
            Alloc=std::allocator<char>,
            Mode=boost::iostreams::detail::io_mode_impl<1>::type
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\stream_buffer.hpp(65) : see reference to class template instantiation 'boost::iostreams::detail::indirect_streambuf<T,Tr,Alloc,Mode>' being compiled
        with
        [
            T=string_source,
            Tr=std::char_traits<char>,
            Alloc=std::allocator<char>,
            Mode=boost::iostreams::detail::io_mode_impl<1>::type
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\utility\base_from_member.hpp(69) : see reference to class template instantiation 'boost::iostreams::stream_buffer<T,Tr,Alloc>' being compiled
        with
        [
            T=string_source,
            Tr=std::char_traits<char>,
            Alloc=std::allocator<char>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\stream.hpp(75) : see reference to class template instantiation 'boost::base_from_member<MemberType>' being compiled
        with
        [
            MemberType=boost::iostreams::stream_buffer<string_source,std::char_traits<char>,std::allocator<char>>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\stream.hpp(112) : see reference to class template instantiation 'boost::iostreams::detail::stream_base<Device,Tr,Alloc>' being compiled
        with
        [
            Device=string_source,
            Tr=std::char_traits<char>,
            Alloc=std::allocator<char>
        ]
        e:\data\tstcsharp\tstiostreams\tstiostreams\tstiostreams.cpp(52) : see reference to class template instantiation 'boost::iostreams::stream<Device>' being compiled
        with
        [
            Device=string_source
        ]
e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\imbue.hpp(38) : error C2039: 'imbue' : is not a member of 'boost::iostreams::detail::imbue_impl<T>'
        with
        [
            T=container_source<std::string>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\adapter\concept_adapter.hpp(113) : see reference to function template instantiation 'void boost::iostreams::imbue<container_source<Container>,Locale>(T &,const Locale &)' being compiled
        with
        [
            Container=std::string,
            Locale=std::locale,
            T=container_source<std::string>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(225) : see reference to function template instantiation 'void boost::iostreams::detail::concept_adapter<T>::imbue<std::locale>(const Locale &)' being compiled
        with
        [
            T=string_source,
            Locale=std::locale
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(223) : while compiling class template member function 'void boost::iostreams::detail::indirect_streambuf<T,Tr,Alloc,Mode>::imbue(const std::locale &)'
        with
        [
            T=string_source,
            Tr=std::char_traits<char>,
            Alloc=std::allocator<char>,
            Mode=boost::iostreams::detail::io_mode_impl<1>::type
        ]
e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\flush.hpp(41) : error C2039: 'flush' : is not a member of 'boost::iostreams::detail::flush_device_impl<T>'
        with
        [
            T=container_source<std::string>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\adapter\concept_adapter.hpp(157) : see reference to function template instantiation 'bool boost::iostreams::flush<Device>(T &)' being compiled
        with
        [
            Device=container_source<std::string>,
            T=container_source<std::string>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\adapter\concept_adapter.hpp(106) : see reference to function template instantiation 'bool boost::iostreams::detail::device_wrapper_impl<boost::iostreams::any_tag>::flush<container_source<Container>,std::basic_streambuf<_Elem,_Traits>>(Device &,Dummy *)' being compiled
        with
        [
            Container=std::string,
            _Elem=char,
            _Traits=std::char_traits<char>,
            Device=container_source<std::string>,
            Dummy=std::basic_streambuf<char,std::char_traits<char>>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\adapter\concept_adapter.hpp(105) : while compiling class template member function 'bool boost::iostreams::detail::concept_adapter<T>::flush(std::basic_streambuf<_Elem,_Traits> *)'
        with
        [
            T=string_source,
            _Elem=char,
            _Traits=std::char_traits<char>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\optional.hpp(35) : see reference to class template instantiation 'boost::iostreams::detail::concept_adapter<T>' being compiled
        with
        [
            T=string_source
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\optional.hpp(38) : see reference to class template instantiation 'boost::iostreams::detail::aligned_storage<T>::dummy_u' being compiled
        with
        [
            T=boost::iostreams::detail::concept_adapter<string_source>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\optional.hpp(108) : see reference to class template instantiation 'boost::iostreams::detail::aligned_storage<T>' being compiled
        with
        [
            T=boost::iostreams::detail::concept_adapter<string_source>
        ]
        e:\data\tstcsharp\boost_1_36_0\include\boost-1_36\boost\iostreams\detail\streambuf\indirect_streambuf.hpp(131) : see reference to class template instantiation 'boost::iostreams::detail::optional<T>' being compiled
        with
        [
            T=boost::iostreams::detail::concept_adapter<string_source>
        ]
tstIostreams - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net