creativity
v1.3.0
Agent-based model of creativity and piracy
|
Validation wrapper base class. More...
#include <creativity/cmdargs/Validation.hpp>
Public Types | |
using | value_type = T |
The type T that this object validates. | |
Public Member Functions | |
Validation (T v) | |
Constructs with an initial value. | |
operator const T & () const | |
Implicit conversion to the stored value. | |
virtual | ~Validation ()=default |
Virtual destructor. | |
Static Public Member Functions | |
static std::string | validationString () |
Returns a string representation of this validation object. | |
Protected Attributes | |
T | val_ |
The stored value. | |
Validation wrapper base class.
This base class does no actual value validation (except one, see below).
This should be inherited from virtually so that subclasses can inherit from multiple Validation subclasses to enforce multiple validations at once.
Note that there is one validation that occurs when using this: if T
is an unsigned type, validation of a Validation (or derived class) makes sure the given value is not negative; without this, boost will cast negative input values to unsigned types, thus ending up with -1 becoming (for an unsigned int) 4294967295.