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 // source_tag
#include
#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 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::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::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' 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' 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
]
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' 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_sourcestd::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(T &,const Locale &)' being compiled
with
[
Container=std::string,
Locale=std::locale,
T=container_sourcestd::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>::imbuestd::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::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_sourcestd::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_sourcestd::string,
T=container_sourcestd::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_implboost::iostreams::any_tag::flush>(Device &,Dummy *)' being compiled
with
[
Container=std::string,
_Elem=char,
_Traits=std::char_traits<char>,
Device=container_sourcestd::string,
Dummy=std::basic_streambuf
]
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
]
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
]
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
]
tstIostreams - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========