auto_any_cast.hpp 485 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef MIGRAPH_GUARD_RTGLIB_AUTO_ANY_CAST_HPP
#define MIGRAPH_GUARD_RTGLIB_AUTO_ANY_CAST_HPP

namespace migraph {

namespace detail {

template<class U>
void any_cast() {}

template<class T>
struct auto_any_caster
{
    T& x;

    template <class U>
    operator U&()
    {
        return any_cast<U>(x);
    }

    operator T&()
    {
        return x;
    }
};

}

template<class T>
detail::auto_any_caster<T> auto_any_cast(T& x)
{
    return {x};
}

} // namespace migraph

#endif