Using boost::variant of pointers to AST nodes, which can contain value of special type std::nullptr_t, indicating emptiness, I faced the problem: generic visitors of the form [] (auto /* const */ * p) { /* use p */; } or of the form:
struct V
{
template< typename T >
void operator () (T /* const */ * p)
{ /* use p */; }
};
can't deal with std::nullptr_t, but static_assert(std::is_pointer< std::nullptr_t >::value); holds for all template arguments of variant visited.
There are a plenty of workarounds one can imagine, but the question rising: is there good explanation why there no (very likely highly restricted) decltype(*nullptr) type in the language (*nullptr is ill-formed and std::remove_pointer_t< std::nullptr_t > is std::nullptr_t in libc++)? Are there theoretical reasons for this?
Aucun commentaire:
Enregistrer un commentaire