[ create a new paste ] login | about

Link: http://codepad.org/CLhyD4tr    [ raw code | output | fork ]

C++, pasted on May 21:
#include <cassert>

template <class T>
void foo()
{
}

/** Determine whether the 'foo' attribute of an object is negative. */
template <class T>
bool foo_negative(T& v)
{
    return v.foo < 0;
}

struct X
{
    int foo;
};

int main()
{
    X x;
    x.foo = 5;
    assert(!foo_negative(x));
    return 0;
}


Output:
1
2
3
In function 'bool foo_negative(T&)':
Line 12: error: parse error in template argument list
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: