Subject: [Boost-bugs] [Boost C++ Libraries] #4617: Use of stringstreams in numeric/ublas/io
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-09-01 14:18:14
#4617: Use of stringstreams in numeric/ublas/io
-----------------------------------------+----------------------------------
Reporter: Kostya <seraphym@â¦> | Owner: guwi17
Type: Bugs | Status: new
Milestone: To Be Determined | Component: uBLAS
Version: Boost 1.44.0 | Severity: Optimization
Keywords: |
-----------------------------------------+----------------------------------
Not 100% sure it is a bug, but use of additional string streams seems a
bit odd.
{{{
template<class E, class T, class ME>
// BOOST_UBLAS_INLINE This function seems to be big. So we do not let
the compiler inline it.
std::basic_ostream<E, T> &operator << (std::basic_ostream<E, T> &os,
const matrix_expression<ME> &m)
{
typedef typename ME::size_type size_type;
size_type size1 = m ().size1 ();
size_type size2 = m ().size2 ();
std::basic_ostringstream<E, T, std::allocator<E> > s;
s.flags (os.flags ());
s.imbue (os.getloc ());
s.precision (os.precision ());
s << '[' << size1 << ',' << size2 << "](";
if (size1 > 0) {
s << '(' ;
if (size2 > 0)
s << m () (0, 0);
for (size_type j = 1; j < size2; ++ j)
s << ',' << m () (0, j);
s << ')';
}
for (size_type i = 1; i < size1; ++ i) {
s << ",(" ;
if (size2 > 0)
s << m () (i, 0);
for (size_type j = 1; j < size2; ++ j)
s << ',' << m () (i, j);
s << ')';
}
s << ')';
return os << s.str ().c_str ();
}
}}}
why do we create stringstream 's' and serialize everything in memory and
only then pump it to 'os'?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/4617> 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:04 UTC