I seem to have missed your paper about changing these things.
THAT YOU NEED TO FIX THE BASIC FUCKING TEMPLATE FEATURES
In an attempt to salvage something of value from this thread, what exactly is the problem with doing explicit, full specialization of types and functions that are declared within a class? Was this just an oversight, or was there some real problem with just allowing it to work as expected?
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.
I can not comment on whether it was originally an oversight, but having proposed it to be changed, and being in the room when EWG approved the change this past meeting - (and assuming my memory is serving me well), I can tell you no one who was present had a good reason for why it was as it was. Let us see what happens in core.
Faisal Vali
I'm usually against trolling but aside from the shocking verbal abuse this guy has leveled at a bunch of hard-working and well-meaning people, I think he has some good arguments which should be considered separately from the ravings that accompanied them.Also, you spelled "genius" wrong.
Generic lambdas don't suffer from a problem here, because the body of the generic lambda is instantiated with the enclosing function template, but presumably the instantiation model for a member template within a local class of a function template would be that the member template is not instantiated at all until a complete set of template arguments for it are known, which may not happen until after the instantiation of the enclosing template has finished and the lexical scope information is gone.
void f(const std::variant<int, char, double> &v)
{
std::visit([](auto &v) { std::cout << v; }, v);
}
void f(const std::variant<int, char, double> &v)
{
struct visitor
{
template<class T>
void operator()(const T &v) const { std::cout << v; }
};
std::visit(visitor{} , v);
}
void f(const std::variant<T1, T2, ...> &v)
{
struct visitor
{
context ctx;
visitor(...) : ctx(...) {}
void operator()(const T1 &v) const; // some specific action for T1
void operator()(const T2 &v) const; // some specific action for T2
template<class T>
void operator()(const T &v) const; // some 'default' action for all other types
};
std::visit(visitor{...} , v);
}
context must be embedded to each lambda.
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/noi1e5%24hbk%241%40blaine.gmane.org.
Here is use case of the latter that explains why it can't replaced by generic lambda:
void f(const std::variant<T1, T2, ...> &v)
{
struct visitor
{
context ctx;
visitor(...) : ctx(...) {}
void operator()(const T1 &v) const; // some specific action for T1template<class T>
void operator()(const T2 &v) const; // some specific action for T2
void operator()(const T &v) const; // some 'default' action for all other types
};
std::visit(visitor{...} , v);
}
One can argue that in this case you can build the visitor using lambdas + overload(). But in this case
context must be embedded to each lambda.
context ctx;
visitor(...) : ctx(...) {}
void operator()(const T1 &v) const; // some specific action for T1
void operator()(const T2 &v) const; // some specific action for T2
template<class T>void f(const std::variant<T1, T2, ...> &v){
struct visitor{
context ctx;
visitor(...) : ctx(...) {}
void operator()(const T1 &v) const; // some specific action for T1template<class T>
void operator()(const T2 &v) const; // some specific action for T2
void operator()(const T &v) const; // some 'default' action for all other types
};
std::visit([ctx = context{...}](const auto& v) {if constexpr(is_same_v<const T1&, decltype(v)>) {} else if constexpr(is_same_v<const T2&, decltype(v)>) {} else {}}, v);
}