Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3027

A 'customised' std::list ??

$
0
0
I'm building some code which uses a library called lua. One of its header files contains a template class which (I think) is some kind of customised std::list - i.e. it's a cutdown version which only includes certain functions from a regular std::list. Here's what it looks like in the header file:-

Code:

  template <class T>
  Class<std::list<T> > beginStdList (char const* name)
  {
    typedef std::list<T> LT;
    return beginConstStdList<T> (name)
      .addFunction("clear", (void (LT::*)()) & LT::clear)
      .addFunction("pop_front", (void (LT::*)()) & LT::pop_front)
      .addFunction("unique", (void (LT::*)()) & LT::unique) // <--- VC2019 COMPILER ERROR HERE !!
      .addFunction("push_front", (void (LT::*)(const T&)) & LT::push_front)
      .addFunction ("push_back", (void (LT::*)(const T&))&LT::push_back);
  }

The code built fine with VC2008 - but VC2019 objects to the "unique" line which gives this compiler error if anything #incudes that header file:-


Code:

error C2440: 'type cast': cannot convert from 'overloaded-function' to 'void (__cdecl std::list<std::string,std::allocator<std::string>>::* )(void)'
F:\libs\lua\LuaBridge\detail\Namespace.h(1905,24): message : None of the functions with this name in scope match the target type

FWIW Namespace.h(1905,24) refers to the section beginning with void (LT::*)() - i.e. at the line that's failing. Does this make sense to anyone here? The function signature seem to be right AFAICT - i.e. std::list::unique() is a function which takes no parameters and returns void

:confused: :confused:

[Edit...] In case it helps, I've just found a few others which give me the same compiler error:-

Code:

.addFunction("front", (void (LT::*)()) & LT::front)
.addFunction("back", (void (LT::*)()) & LT::back)
.addFunction("end", (void (LT::*)()) & LT::end)

Can anyone think of something which those particular functions have in common but which isn't shared by the ones that work - sort() / empty() / clear() / reverse() etc ??

Viewing all articles
Browse latest Browse all 3027

Latest Images

Trending Articles



Latest Images