Question: I am in the process of converting a large set of geospatial code from one projection to another. To enforce proper units during this conversion, I have introduced Distance, Point, Rectangle, and Polygon templates which take a tag indicating what coordinate system is used. This is working out fairly well, but there are a lot of places where checks are performed for non-zero (`!= 0`) or positive values (`> 0`). I would like to be able to overload these operators to allow comparing against `0` without comparing against any other number. Is it possible to accomplish this?

As an additional restriction, I cannot use `constexpr` because I must support VS 2013, but I'd still be interested to hear if there is a way to do this with `constexpr`

Just for reference, I am working with something like this:

```
template<typename Tag> struct Distance
{
  int value;
};

template<typename Tag> struct Point
{
  Distance<Tag> x;
  Distance<Tag> y;
};

// This works fine for comparing two Distances
template<typename Tag> bool operator>(const Distance<Tag>& a, const Distance<Tag>& b) {return a.value > b.value;}
// But I don't want this to allow a > 14, only a > 0
template<typename Tag> bool operator>(const Distance<Tag>& a, int b) {return a.value > b;}

struct Mercator;
typedef Point<Mercator> MercPoint;
struct GuiScale;
typedef Point<GuiScale> GuiPoint;
// etc.

```

Answer: 
You may use `nullptr_t` as a hack (as literal `0` convert to `nullptr`):

```
template<typename Tag> bool operator>(const Distance<Tag>& a, std::nullptr_t b) {return a.value > 0;}

```
You might use the conversion-to-any-pointer of a literal zero:

```
#include <type_traits>

template<typename Tag>
struct Distance
{
private:
    using literal_zero = void(Distance::*)();

    template<typename U>
    using enable_nullptr = typename std::enable_if<
        std::is_same< typename std::decay< U >::type, std::nullptr_t >::value
    >::type;

public:
    int value;

    bool operator<( literal_zero ) const { return value < 0; }

    template<typename U>
    enable_nullptr<U> operator<( const U& ) const = delete;
};

int main() {
    Distance<int> a;
    a.value = 0;

    a < 0;
    // a < 42; // does not compile
    // a < nullptr; // does not compile
}

```

This, unlike the other answer, also disallows `a < nullptr`. Also, if you remove the `nullptr`-related part and replace the `using literal_zero = ...` with a `typedef`, the same technique works with C++98.

[**Live example**](http://coliru.stacked-crooked.com/a/81c746a43ddcf2ee)