samedi 5 décembre 2015

How to check if type provides function with arithmetic type

I want to check if type provided in template has methond which gets size_t type and return arithmetic type. For int it looks like

template <typename U>
struct has<U> {
    template <typename T, T>
    struct helper;
    template <typename T>
    static std::uint8_t check(helper<int (*)(size_t), &T::function_name>*);
    template <typename T>
    static std::uint16_t check(...);

    static constexpr bool value = sizeof(check<U>(0)) == sizeof(std::uint8_t);
};

but how it looks like for all arithmetic types?

Aucun commentaire:

Enregistrer un commentaire