Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. variadic templates problem

variadic templates problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++wpfquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FriendOfAsherah
    wrote on last edited by
    #1

    Im using this for the first time for mapping a function "f" with variable count of parameters declarition:

    template void AllItemsO(void (*f)(A...), A... args)
    {
    // for (auto _F : *this)
    // if ((_F)) ((_F)->*f)(args);
    }

    call in cpp:

    AllItemsO(&IcompDWO3D::SetObjMat, visInfo, pci, doit, obj);

    function to call is: IcompDWO3D::SetObjMat parameters: visInfo, pci, doit, obj compiler always shows up an error C2784 Fehler 1 error C2784: "void CapDWOICollection::AllItemsO(void (__cdecl *)(A...),A...)": template-Argument für "void (__cdecl *)(IapVisibilityInfo *,IPickCookie *,aprivis::MakeSubObjSpecial,aprivis::avhObjectWrapper &,A...)" konnte nicht von "void (__thiscall component::IcompDWO3D::* )(IapVisibilityInfo *,IPickCookie *,aprivis::MakeSubObjSpecial,aprivis::avhObjectWrapper &)" hergeleitet werden. looking at what I have shown bold, it seems that it cannot spread the functionparameters form the A... variadic to single paarameters? A non variadic verison with 2 Parameters looks like this and works:

    template void AllItemsO2(void (*f)(T1, T2), T1 p1, T2 p2)
    { for (auto _F : *this) if (_F) ((_F)->*f)(p1, p2); }

    any help for my syntax?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups