vendredi 5 octobre 2018

Template type transformation needed to store various value classes?

I'd like to have a class with a shared_ptr who's value can be accessed through a getter. Something like this:

template <class T>
struct async_result {
    T& value() {
        return *ptr_;
    }

private:
    std::shared_ptr<T> ptr_;
};

Which works fine with regular value classes. I'll have a specialization for the case T=void, but I'd like to be able to store references and pointers in this as way as well. What sort of transformations on T do I need to perform to decay types appropriately?

Aucun commentaire:

Enregistrer un commentaire