2
0
mirror of https://github.com/boostorg/hof.git synced 2026-01-23 17:42:40 +00:00
Files
hof/test/implicit.cpp
2014-07-18 13:24:18 -04:00

32 lines
543 B
C++

#include <fit/implicit.h>
#include "test.h"
template<class T>
struct auto_caster
{
template<class U>
T operator()(U x)
{
return T(x);
}
};
struct auto_caster_foo
{
int i;
explicit auto_caster_foo(int i) : i(i) {}
};
// TODO: Test template constraint on conversion operator
fit::implicit<auto_caster> auto_cast = {};
FIT_TEST_CASE()
{
float f = 1.5;
int i = auto_cast(f);
// auto_caster_foo x = 1;
auto_caster_foo x = auto_cast(1);
FIT_TEST_CHECK(1 == i);
FIT_TEST_CHECK(1 == x.i);
}