summaryrefslogtreecommitdiff
path: root/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/expressions/notexpression.h
blob: 4785f07bca43166cac923700414bd3dc34a40c85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//          Copyright Joakim Karlsson & Kim Gräsman 2010-2012.
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)

#ifndef IGLOO_NOTEXPRESSION_H
#define IGLOO_NOTEXPRESSION_H
  
#include "./expression_fwd.h"

namespace snowhouse {

  template< typename ExpressionType >
  struct NotExpression : Expression< NotExpression<ExpressionType> >
  {
    NotExpression(const ExpressionType& expression)
      : m_expression(expression)
    {
    }

    template<typename ActualType>
    bool operator()(const ActualType& actual) const
    {
      return !m_expression(actual);
    }

    ExpressionType m_expression;
  };

  template< typename ExpressionType >
  struct Stringizer< NotExpression<ExpressionType> >
  {
    static std::string ToString(const NotExpression<ExpressionType>& expression)
    {
      std::ostringstream builder;
	  builder << "not " << snowhouse::Stringize(expression.m_expression);

      return builder.str();
    }
  };
}

#endif