Boost logo

Boost :

From: George M. Garner Jr. (gmgarner_at_[hidden])
Date: 2004-09-13 16:42:48


Johnathan,

> typedef converter< reference_wrapper<std::ostream> > my_converter;
> stream_facade<my_converter> out;
> out.open(my_converter(ref(std::cout), whatever_locale));
> out << L"Hello Wide World!\n"; <

This doesn't compile. I get the following error:

h:\source
code\Turkanis\iostream\boost\io\detail\adapters\resource_wrapper.hpp(39) :
error C2100: illegal indirection
h:\source
code\Turkanis\iostream\boost\io\detail\adapters\resource_wrapper.hpp(39) :
while compiling class-template member function 'boost::reference_wrapper<T>
&boost::io::detail::resource_wrapper<Resource>::operator *(void)'
with
[
T=std::ostream,
Resource=boost::reference_wrapper<std::ostream>
]
h:\source code\boost\boost_1_31_0\boost\optional.hpp(95) : see reference to
class template instantiation 'boost::io::detail::resource_wrapper<Resource>'
being compiled
with
[
Resource=boost::reference_wrapper<std::ostream>
]
h:\source code\boost\boost_1_31_0\boost\optional.hpp(98) : see reference to
class template instantiation
'boost::optional_detail::aligned_storage<T>::dummy_u' being compiled
with
[
T=boost::optional_detail::optional_base<boost::io::detail::resource_wrapper<boost::reference_wrapper<std::ostream>>>::internal_type
]
h:\source code\boost\boost_1_31_0\boost\optional.hpp(357) : see reference to
class template instantiation 'boost::optional_detail::aligned_storage<T>'
being compiled
with
[
T=boost::optional_detail::optional_base<boost::io::detail::resource_wrapper<boost::reference_wrapper<std::ostream>>>::internal_type
]
h:\source code\boost\boost_1_31_0\boost\optional.hpp(364) : see reference to
class template instantiation 'boost::optional_detail::optional_base<T>'
being compiled
with
[
T=boost::io::detail::resource_wrapper<boost::reference_wrapper<std::ostream>>
]
h:\source code\Turkanis\iostream\boost\io\converter.hpp(138) : see reference
to class template instantiation 'boost::optional<T>' being compiled
with
[
T=boost::io::detail::resource_wrapper<boost::reference_wrapper<std::ostream>>
]
h:\source code\Turkanis\iostream\boost\io\converter.hpp(162) : see reference
to class template instantiation
'boost::io::detail::converter_impl<Resource,Int,Ext,State,Alloc>' being
compiled
with
[
Resource=boost::reference_wrapper<std::ostream>,
Int=wchar_t,
Ext=boost::io::converter<boost::reference_wrapper<std::ostream>>::extern_type,
State=boost::io::converter<boost::reference_wrapper<std::ostream>>::state_type,
Alloc=std::allocator<char>
]
h:\source code\Turkanis\iostream\boost\io\io_traits.hpp(38) : see reference
to class template instantiation 'boost::io::converter<Resource>' being
compiled
with
[
Resource=boost::reference_wrapper<std::ostream>
]
h:\source code\Turkanis\iostream\boost\io\io_traits.hpp(47) : see reference
to class template instantiation 'boost::io::detail::member_char_type<T>'
being compiled
with
[
T=my_converter
]
h:\source code\Turkanis\iostream\boost\io\stream_facade.hpp(81) : see
reference to class template instantiation 'boost::io::char_type<T>' being
compiled
with
[
T=my_converter
]
Regards,

George.

"Jonathan Turkanis" <technews_at_[hidden]> wrote in message
news:chsl49$e6v$1_at_sea.gmane.org...
>
> "George M. Garner Jr." <gmgarner_at_[hidden]> wrote in message
> news:chr8dl$8rr$1_at_sea.gmane.org...
>> Johnathan,
>>
>> How do I do locale specific Unicode-to-Multibyte conversion. As I
>> understand the current design I need to do something like this:
>>
>> filtering_wostream out;
>> out.push(unicode_to_multibyte_output_filter<__wchar_t>(locale));
>> out.push(cout);
>> out << L"This gets converted to multibyte characters according to the
>> current locale." << endl;
>
> The problem is really that I haven't finished writing the components that
> make
> this easy. For this, I apologize. (See User's Guide-->Code Conversion.)
>
> The *easiest* way to do what you want should be this:
>
> converting_ostream out;
> out.push(std::cout);
> out.imbue( some_locale );
> out << L"This gets converted to multibyte characters";
>
> This will also allow any number of wide- and narrow- character filters
> before
> cout, as long as all the wide ones come first. But as I said, this
> component is
> not ready yet.
>
> The current way to do this is extremely verbose:
>
> typedef converter< reference_wrapper<std::ostream> > my_converter;
> stream_facade<my_converter> out;
> out.open(my_converter(ref(std::cout), whatever_locale));
> out << L"Hello Wide World!\n";
>
> Reference wrapper is required here because std::ostream is non-copyable.
> The
> above code really should be
>
> typedef converter<std::ostream> my_converter;
> stream_facade<my_converter> out;
> out.open(my_converter(std::cout, whatever_locale));
> out << L"Hello Wide World!\n";
>
> but I forgot to make the template converter do the reference-wrapping
> automatically. (I'll fix this.)
>
> There's one last problem. The file
> boost/io/detail/streambufs/indirect_streambufs contains this code:
>
> enum {
> f_open = 1,
> f_input_closed = f_open << 1,
> f_output_closed = f_input_closed << 1,
> f_output_buffered = f_output_closed
> };
>
> This should be
>
> enum {
> f_open = 1,
> f_input_closed = f_open << 1,
> f_output_closed = f_input_closed << 1,
> f_output_buffered = f_output_closed << 1
> };
>
> I'm not sure if it will make a difference in the above case.
>
> To summarize: what you want to do is perfectly resonable and should be
> easy, but
> I haven't finished developing all the components. The current method is
> unnecessarily verbose, but should work.
>
> Thanks again!
>
> Jonathan
>
>
>
>
>
>
>
>
>
>
>
>
>
>>
>> But the second to last line will generate an error with the present
>> design
>> because I am attaching a narrow character stream to a wide character
>> filtering ostream. Do I need to use the boost::io::copy() paradigm? :(-
>>
>> Regards,
>>
>> George.
>>
>>
>>
>> _______________________________________________
>> Unsubscribe & other changes:
>> http://lists.boost.org/mailman/listinfo.cgi/boost
>>
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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