tree-sitter/spec/compiler/helpers/equals_pointer.h

38 lines
1.1 KiB
C
Raw Normal View History

#ifndef HELPERS_EQUALS_POINTER_H_
#define HELPERS_EQUALS_POINTER_H_
2014-02-17 12:45:53 -08:00
2014-08-06 13:00:35 -07:00
#include "bandit/bandit.h"
2014-02-17 12:45:53 -08:00
#include <string>
namespace snowhouse {
2014-08-06 13:00:35 -07:00
using namespace std;
template<typename ExpectedType>
struct EqualsPointerConstraint : Expression<EqualsPointerConstraint<ExpectedType>> {
EqualsPointerConstraint(const ExpectedType& expected) : expected(expected) {}
template<typename ActualType>
bool operator()(const ActualType& actual) const {
return *expected == *actual;
2014-08-06 13:00:35 -07:00
}
ExpectedType expected;
};
template<typename ExpectedType>
struct Stringizer<EqualsPointerConstraint<ExpectedType>> {
static string ToString(const EqualsPointerConstraint<ExpectedType>& constraint) {
ostringstream builder;
builder << "pointer to " << snowhouse::Stringize(constraint.expected);
return builder.str();
2014-02-17 12:45:53 -08:00
}
2014-08-06 13:00:35 -07:00
};
template<typename ExpectedType>
inline EqualsPointerConstraint<ExpectedType> EqualsPointer(const ExpectedType& expected) {
return EqualsPointerConstraint<ExpectedType>(expected);
}
2014-02-17 12:45:53 -08:00
}
#endif // HELPERS_EQUALS_POINTER_H_