Adjust code to perform to C++ standard according to gcc-3.4

interpretation... (Have not compiled/checked/changed paradisEO.)

That is, the current code compiles with gcc-3.4 and the checks
(besides t-MGE1bit) all pass.
This commit is contained in:
kuepper 2004-12-23 15:29:07 +00:00
commit 85a326c5e4
35 changed files with 1057 additions and 864 deletions

View file

@ -3,7 +3,7 @@
//-----------------------------------------------------------------------------
// eoPopStat.h
// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001
/*
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@ -43,25 +43,28 @@ that can be used to dump to the screen
/** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats.
This snippet is a workaround:
This snippet is a workaround:
This class will "print" a whole population into a std::string - that you can later
send to any stream
This is the plain version - see eoPopString for the Sorted version
Note: this Stat should probably be used only within eoStdOutMonitor, and not
Note: this Stat should probably be used only within eoStdOutMonitor, and not
inside an eoFileMonitor, as the eoState construct will work much better there.
*/
template <class EOT>
class eoPopStat : public eoStat<EOT, std::string>
{
public :
/** default Ctor, void std::string by default, as it appears
public:
using eoPopStat< EOT>::value;
/** default Ctor, void std::string by default, as it appears
on the description line once at beginning of evolution. and
is meaningless there. _howMany defaults to 0, that is, the whole
population*/
eoPopStat(unsigned _howMany = 0, std::string _desc ="")
eoPopStat(unsigned _howMany = 0, std::string _desc ="")
: eoStat<EOT, std::string>("", _desc), combien( _howMany) {}
/** Fills the value() of the eoParam with the dump of the population.
Adds a \n before so it does not get mixed up with the rest of the stats
that are written by the monitor it is probably used from.
@ -73,9 +76,9 @@ void operator()(const eoPop<EOT>& _pop)
unsigned howmany=combien?combien:_pop.size();
for (unsigned i = 0; i < howmany; ++i)
{
std::ostringstream os;
std::ostringstream os;
os << _pop[i] << std::endl;
// paranoid:
value() += os.str();
}
@ -91,7 +94,7 @@ void operator()(const eoPop<EOT>& _pop)
{
std::ostrstream os(buffer, 1022); // leave space for emergency terminate
os << _pop[i] << std::endl << std::ends;
// paranoid:
buffer[1022] = '\0';
value() += buffer;
@ -104,40 +107,45 @@ private:
};
/** Thanks to MS/VC++, eoParam mechanism is unable to handle std::vectors of stats.
This snippet is a workaround:
This snippet is a workaround:
This class will "print" a whole population into a std::string - that you can later
send to any stream
This is the Sorted version - see eoPopString for the plain version
Note: this Stat should probably be used only within eoStdOutMonitor, and not
Note: this Stat should probably be used only within eoStdOutMonitor, and not
inside an eoFileMonitor, as the eoState construct will work much better there.
*/
template <class EOT>
class eoSortedPopStat : public eoSortedStat<EOT, std::string>
{
public :
/** default Ctor, void std::string by default, as it appears
* on the description line once at beginning of evolution. and
* is meaningless there _howMany defaults to 0, that is, the whole
* population
*/
eoSortedPopStat(unsigned _howMany = 0, std::string _desc ="") :
eoSortedStat<EOT, std::string>("", _desc) , combien( _howMany) {}
/** Fills the value() of the eoParam with the dump of the population.
Adds a \n before so it does not get mixed up with the rest of the stats
that are written by the monitor it is probably used from.
*/
public:
using eoSortedPopStat< EOT>::value;
/** default Ctor, void std::string by default, as it appears on
the description line once at beginning of evolution. and is
meaningless there _howMany defaults to 0, that is, the whole
population
*/
eoSortedPopStat(unsigned _howMany = 0, std::string _desc ="")
: eoSortedStat<EOT, std::string>("", _desc) , combien( _howMany)
{}
/** Fills the value() of the eoParam with the dump of the
population. Adds a \n before so it does not get mixed up with
the rest of the stats that are written by the monitor it is
probably used from.
*/
#ifdef HAVE_SSTREAM
void operator()(const std::vector<const EOT*>& _pop)
{
value() = ""; // empty
void operator()(const std::vector<const EOT*>& _pop)
{
value() = ""; // empty
unsigned howMany=combien?combien:_pop.size();
for (unsigned i = 0; i < howMany; ++i)
{
std::ostringstream os;
std::ostringstream os;
os << *_pop[i] << std::endl;
// paranoid:
value() += os.str();
}
@ -146,13 +154,13 @@ public :
void operator()(const std::vector<const EOT*>& _pop)
{
char buffer[1023]; // about one K of space per member
value() = ""; // empty
value() = ""; // empty
unsigned howMany=combien?combien:_pop.size();
for (unsigned i = 0; i < howMany; ++i)
{
std::ostrstream os(buffer, 1022); // leave space for emergency terminate
os << *_pop[i] << std::endl << std::ends;
// paranoid:
buffer[1022] = '\0';
value() += buffer;