Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6160: support for (istream >> array < char >)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-11-28 17:08:26
#6160: support for (istream >> array < char >)
------------------------------------+---------------------------------------
Reporter: giecrilj@⦠| Owner: marshall
Type: Feature Requests | Status: assigned
Milestone: To Be Determined | Component: array
Version: Boost 1.44.0 | Severity: Cosmetic
Resolution: | Keywords:
------------------------------------+---------------------------------------
Comment (by ne01026@â¦):
Replying to [comment:8 marshall]:
> Replying to [comment:7 ne01026@â¦]:
> > Replying to [comment:6 marshall]:
> > > Replying to [comment:4 ne01026@â¦]:
> > > > `char []` has unknown length, `array < char >` has known length,
therefore `>> array` is safer than `>> char []`, and my code, attached,
q.v., uses this information to prevent buffer overflow.
> > >
> > > `char []` has known length - sizeof is your friend here.
> >
> > `sizeof (char [])` is undefined.
>
> Sorry - I was imprecise: char [N] has size N for all N > 0
Unfortunately, the standard library does not provide `istream >> char (&)
[N]` as some older compilers are unable to match against such a template,
so the best we can do is to define this thing for array.
> BTW - if this were to become part of boost, it would be more
complicated. You should be able to extract from std::wcin to a
boost::array<wchar_t>, for example.
I already do, that is why the code is so ugly :-(
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6160#comment:9> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC