mardi 5 janvier 2016

Create a renamed function from template function reference

I don't really know how to rename the function below. The example only works with template specialization.

    template<typename A, typename B>
    auto MAX(const A &one, const B &two) -> decltype(one > two ? one : two) {
        static_assert(std::is_floating_point<A>::value || std::is_integral<A>::value, "ERROR - bigger(): template parameters not of type float or int\n");
        static_assert(std::is_floating_point<B>::value || std::is_integral<B>::value, "ERROR - bigger(): template parameters not of type float or int\n"); 

        return one > two ? one : two;
    }

    template<typename A, typename B>
    const auto min = &MAX<A,B>;

Works:

    const auto min = &MAX<float,float>;

Aucun commentaire:

Enregistrer un commentaire