samedi 30 mai 2015

Is typename required or not here?

Consider the code:

#include <memory>

template <class T, class Deleter = std::default_delete<T>>
class unique_ptr_wrapper: public std::unique_ptr<T, Deleter>
{
public:
    using typename std::unique_ptr<T, Deleter>::unique_ptr;
    operator T* () const {return this->get();}
};

int main()
{
    unique_ptr_wrapper<int> upw{new int{42}};
}

g++5.1 compiles it fine, although clang++ complains

error: typename is allowed for identifiers only

I agree that we don't have an identifier here, so probably typename is not required. But is it actually forbidden? Is the compiler required to at least emit a diagnostic?

Aucun commentaire:

Enregistrer un commentaire