Re: A 'customised' std::list ??
Over on the Microsoft forum one of the contributers suggested adding an extra line which - by some strange magic - seems to fix the compile:-
Code:
#include <list>
using LT = std::list<int>;
using func_void_t = void(LT::*)();
using func_ref_t = LT::reference(LT::*)();
using func_iter_t = LT::iterator(LT::*)();
using unused = decltype(std::declval<LT>().unique()); // <--- New line
int main (int argc, char *argv[])
{
// Non-overloaded members
[...]
// Members with overloads
[...]
func_void_t f5 = <::unique; // Now succeeds !!!
return 0;
}
But even over there they reckon it's a compiler bug and needs to get reported to the VC development team.
Re: A 'customised' std::list ??
The Bug has now been reported to the VS team and is now 'Under Investigation'. I'll update when there is more info.
Nice workaround! I'd never of thought of that as that using unused... line should have absolutely no effect!
Re: A 'customised' std::list ??
Did the VS team ever produce an explanation for this - or a fix?
Re: A 'customised' std::list ??
No. It's still marked as 'under investigation'. I guess they accept this as a bug, but that it's low on their priority list. When they'll get around to issuing a fix is really anyone's guess....
Re: A 'customised' std::list ??
Since the list contains pointers, rather than objects, you'll have to provide a custom comparator to compare the objects they point to. And since you're using a list, you have to use its own sort method: the generic std::sort algorithm only works on random-access sequences.
EventList.sort([](Event * lhs, Event * rhs) {return lhs->time < rhs->time;});
or, if you're stuck in the past and can't use lambdas:
struct CompareEventTime {
bool operator()(Event * lhs, Event * rhs) {return lhs->time < rhs->time;}
};
EventList.sort(CompareEventTime());
If the list contained objects (as it probably should), then it might make sense to provide a comparison operator instead:
bool operator<(Event const & lhs, Event const & rhs) {return lhs.time < rhs.time;}
std::list<Event> EventList;
//...
EventList.sort();