expose ScalarType in eoScalarFitness
This commit is contained in:
parent
2da161fc85
commit
124701a364
1 changed files with 12 additions and 11 deletions
|
|
@ -48,18 +48,19 @@
|
||||||
* Suitable constructors and assignments and casts are defined to work
|
* Suitable constructors and assignments and casts are defined to work
|
||||||
* with this quantity as if it were a ScalarType.
|
* with this quantity as if it were a ScalarType.
|
||||||
*/
|
*/
|
||||||
template <class ScalarType, class Compare >
|
template <class SCALAR, class CMP>
|
||||||
class eoScalarFitness
|
class eoScalarFitness
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
using ScalarType = SCALAR;
|
||||||
|
|
||||||
eoScalarFitness() : value() {}
|
eoScalarFitness() : value() {}
|
||||||
eoScalarFitness(const eoScalarFitness& other) : value(other.value) {}
|
eoScalarFitness(const eoScalarFitness& other) : value(other.value) {}
|
||||||
eoScalarFitness(const ScalarType& v) : value(v) {}
|
eoScalarFitness(const SCALAR& v) : value(v) {}
|
||||||
|
|
||||||
eoScalarFitness& operator=(const eoScalarFitness& other)
|
eoScalarFitness& operator=(const eoScalarFitness& other)
|
||||||
{ value = other.value; return *this; }
|
{ value = other.value; return *this; }
|
||||||
eoScalarFitness& operator=(const ScalarType& v)
|
eoScalarFitness& operator=(const SCALAR& v)
|
||||||
{ value = v; return *this; }
|
{ value = v; return *this; }
|
||||||
|
|
||||||
/** Conversion operator: it permits to use a fitness instance as its scalar
|
/** Conversion operator: it permits to use a fitness instance as its scalar
|
||||||
|
|
@ -69,27 +70,27 @@ class eoScalarFitness
|
||||||
* fit = val;
|
* fit = val;
|
||||||
* val = fit;
|
* val = fit;
|
||||||
*/
|
*/
|
||||||
operator ScalarType(void) const { return value; }
|
operator SCALAR(void) const { return value; }
|
||||||
|
|
||||||
/// Comparison, using less by default
|
/// Comparison, using less by default
|
||||||
bool operator<(const eoScalarFitness& other) const
|
bool operator<(const eoScalarFitness& other) const
|
||||||
{ return Compare()(value, other.value); }
|
{ return CMP()(value, other.value); }
|
||||||
|
|
||||||
/// Comparison, using less by default
|
/// Comparison, using less by default
|
||||||
// needed for MSVC 8 (MSVC 2005) added by J.Eggermont 20-11-2006
|
// needed for MSVC 8 (MSVC 2005) added by J.Eggermont 20-11-2006
|
||||||
bool operator<(const ScalarType& other) const
|
bool operator<(const SCALAR& other) const
|
||||||
{ return Compare()(value, other); }
|
{ return CMP()(value, other); }
|
||||||
|
|
||||||
// implementation of the other operators
|
// implementation of the other operators
|
||||||
bool operator>( const eoScalarFitness<ScalarType, Compare>& y ) const { return y < *this; }
|
bool operator>( const eoScalarFitness<SCALAR, CMP>& y ) const { return y < *this; }
|
||||||
// implementation of the other operators
|
// implementation of the other operators
|
||||||
bool operator<=( const eoScalarFitness<ScalarType, Compare>& y ) const { return !(*this > y); }
|
bool operator<=( const eoScalarFitness<SCALAR, CMP>& y ) const { return !(*this > y); }
|
||||||
// implementation of the other operators
|
// implementation of the other operators
|
||||||
bool operator>=(const eoScalarFitness<ScalarType, Compare>& y ) const { return !(*this < y); }
|
bool operator>=(const eoScalarFitness<SCALAR, CMP>& y ) const { return !(*this < y); }
|
||||||
|
|
||||||
|
|
||||||
private :
|
private :
|
||||||
ScalarType value;
|
SCALAR value;
|
||||||
};
|
};
|
||||||
/** @example t-eofitness.cpp
|
/** @example t-eofitness.cpp
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue