Tick
Tick copied to clipboard
TICK_MEMBER_REQUIRES_OC for outside-class-definitions of members
Nice Library.
This pullrequest adds the possibility to use TICK_MEMBER_REQUIRES
(_OC
); also for members that are defined outside of the class.
Example.
#include "tick/requires.h"
#include "tick/builder.h"
#include <iostream>
TICK_TRAIT(is_incrementable)
{
template<class T>
auto require(T&& x) -> valid<
decltype(x++),
decltype(++x)
>;
};
template<class T>
struct foo
{
T x = 0; // C++11 in-member initialization
TICK_MEMBER_REQUIRES(is_incrementable<T>())
void up();
};
template<class T>
TICK_MEMBER_REQUIRES_OC(is_incrementable<T>()) // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void foo<T>::up()
{
x++;
}
int main()
{
foo<int> f;
std::cout << f.x << std::endl;
f.up();
std::cout << f.x << std::endl;
return 0;
}
Thanks, are you able to add some tests?
Ok, I've added a test which uses normal assert
to check the actual invocation of a member function, whose code is defined oc (outside the class).
Thanks. I've just added support for Visual Studio. However, this won't work for msvc, since msvc needs to use the __LINE__
macro. I think I'll try to merge this in, but it will only be supported on C++ compilers. For portability, its best to define it inline.