2
0
mirror of https://github.com/boostorg/hof.git synced 2026-01-20 16:42:14 +00:00
Files
hof/test/implicit.cpp
2016-01-18 08:05:51 -06:00

33 lines
567 B
C++

#include <fit/implicit.hpp>
#include "test.hpp"
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 ip) : i(ip) {}
};
// TODO: Test template constraint on conversion operator
static constexpr 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);
}