blitzdg
an open-source project aiming to implement parallel discontinuous Galerkin (dg) solvers for common partial differential equations systems using blitz++ for array and tensor manipulations and MPI for distributed parallelism.
isgreaterthanconstraint.h
1 
2 // Copyright Joakim Karlsson & Kim Gräsman 2010-2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #ifndef IGLOO_ISGREATERTHANCONSTRAINT_H
8 #define IGLOO_ISGREATERTHANCONSTRAINT_H
9 
10 #include "./expressions/expression.h"
11 
12 namespace snowhouse {
13 
14  template< typename ExpectedType >
15  struct IsGreaterThanConstraint : Expression< IsGreaterThanConstraint<ExpectedType> >
16  {
17  IsGreaterThanConstraint(const ExpectedType& expected)
18  : m_expected(expected)
19  {
20  }
21 
22  template<typename ActualType>
23  bool operator()(const ActualType& actual) const
24  {
25  return (actual > m_expected);
26  }
27 
28  ExpectedType m_expected;
29  };
30 
31  template< typename ExpectedType >
32  inline IsGreaterThanConstraint<ExpectedType> IsGreaterThan(const ExpectedType& expected)
33  {
35  }
36 
37  inline IsGreaterThanConstraint<std::string> IsGreaterThan(const char* expected)
38  {
39  return IsGreaterThanConstraint<std::string>(expected);
40  }
41 
42  template< typename ExpectedType >
43  struct Stringizer< IsGreaterThanConstraint< ExpectedType > >
44  {
45  static std::string ToString(const IsGreaterThanConstraint<ExpectedType>& constraint)
46  {
47  std::ostringstream builder;
48  builder << "greater than " << snowhouse::Stringize(constraint.m_expected);
49 
50  return builder.str();
51  }
52  };
53 }
54 
55 #endif
Definition: assert.h:13
Definition: stringize.h:71
Definition: expression.h:17
Definition: isgreaterthanconstraint.h:15