cfgfile 0.2.11
Loading...
Searching...
No Matches
constraint_min_max.hpp
Go to the documentation of this file.
1
31#ifndef CFGFILE__CONSTRAINT_MIN_MAX_HPP__INCLUDED
32#define CFGFILE__CONSTRAINT_MIN_MAX_HPP__INCLUDED
33
34// cfgfile include.
35#include "constraint.hpp"
36
37
38namespace cfgfile {
39
40//
41// constraint_min_max_t
42//
43
48template< class T >
50 : public constraint_t< T >
51{
52public:
54 constraint_min_max_t( const T & min, const T & max )
55 : m_min( min )
56 , m_max( max )
57 {
58 }
59
63
71 bool check( const T & value ) const override
72 {
73 return ( m_min <= value && value <= m_max );
74 }
75
76private:
78 T m_min;
80 T m_max;
81}; // class constraint_min_max_t
82
83} /* namespace cfgfile */
84
85#endif // CFGFILE__CONSTRAINT_MIN_MAX_HPP__INCLUDED
Constraint that allowed values to be in the given range: min <= value <= max.
Definition constraint_min_max.hpp:51
constraint_min_max_t(const T &min, const T &max)
Construct constraint.
Definition constraint_min_max.hpp:54
~constraint_min_max_t()
Definition constraint_min_max.hpp:60
bool check(const T &value) const override
Check value for correctness.
Definition constraint_min_max.hpp:71
Base class for constraints.
Definition constraint.hpp:43
Definition const.hpp:38