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.
fulfillsconstraint.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 FULFILLSCONSTRAINT_H
8 #define FULFILLSCONSTRAINT_H
9 
10 #include "./expressions/expression.h"
11 
12 namespace snowhouse {
13 
14  template< typename MatcherType >
15  struct FulfillsConstraint : Expression< FulfillsConstraint<MatcherType> >
16  {
17  FulfillsConstraint(const MatcherType& matcher)
18  : m_matcher(matcher)
19  {
20  }
21 
22  template<typename ActualType>
23  bool operator()(const ActualType& actual) const
24  {
25  return m_matcher.Matches(actual);
26  }
27 
28  MatcherType m_matcher;
29  };
30 
31  template< typename MatcherType >
32  inline FulfillsConstraint<MatcherType> Fulfills(const MatcherType& matcher)
33  {
34  return FulfillsConstraint<MatcherType>(matcher);
35  }
36 
37  template< typename MatcherType >
38  struct Stringizer< FulfillsConstraint< MatcherType > >
39  {
40  static std::string ToString(const FulfillsConstraint<MatcherType>& constraint)
41  {
42  std::ostringstream builder;
43  builder << snowhouse::Stringize(constraint.m_matcher);
44 
45  return builder.str();
46  }
47  };
48 
49 }
50 
51 #endif
Definition: assert.h:13
Definition: fulfillsconstraint.h:15
Definition: stringize.h:71
Definition: expression.h:17