hof icon indicating copy to clipboard operation
hof copied to clipboard

implicit semantics not clear enough

Open viboes opened this issue 8 years ago • 1 comments

It is not clear to me from http://pfultz2.github.io/Fit/doc/html/implicit/index.html the semantics of implicit as the T is not part of the implicit parameters

assert(T(implicit<F>()(xs...)) == F<T>()(xs...));

IIUC, what you mean is that the the Tconversion operator of implicit<F>()(xs...) behaves like F<T>()(xs...))

I had a implicitly function that wrapped a type U and provided an implicit conversion to any type (something similar to your auto_cast)

template<class U>
struct implicitly_wrapper
{
    U x;
    implicitly_wrapper(T x) : x(x) {}
    template<class T>
    operator T()
    {
        return T(x);
    }
};

template<class U>
implicitly_wrapper<decay_t<U>> implicitly(U&& u) 
{
    return implicitly_wrapper<decay_t<U>>(std::forward<U>(u)); 
}

Do you have other examples of use of 'implicit'?

viboes avatar Mar 05 '16 14:03 viboes

IIUC, what you mean is that the the Tconversion operator of implicit<F>()(xs...) behaves like F<T>()(xs...))

Yes, that's correct. I am not sure how to make the semantics clearer.

Do you have other examples of use of 'implicit'?

A to_container function would work to convert any range to a container, and it could deduce the container type from it get assigned to.

pfultz2 avatar Mar 25 '16 20:03 pfultz2