#include <type_traits>

template <typename T>
struct Ref
{
    T &t;
    Ref(T &_t) : t(_t) {}
    Ref(const Ref<typename std::remove_cv<T>::type>& other) : t(other.t) {}
};

template <typename T>
Ref<T> MakeRef(T& t) { return {t}; }

template <typename T>
Ref<const T> MakeConstRef(const T& t) { return {t}; }

int main()
{
    int foo = 5;
    auto r = MakeConstRef(foo);
    auto c = r;            //This should be allowed.
    auto other = MakeRef(foo);  //This should also be allowed.
    Ref<const int> baz = other;  // This should work, too.
    Ref<int> bar = c;                //This should fail to compile somehow.
}
