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. vector of doubles (division)

vector of doubles (division)

Scheduled Pinned Locked Moved C / C++ / MFC
databasegraphicsquestion
22 Posts 5 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.
  • B b rad311

    Thanks Ash. I implemented the code, but it is giving many errors, the first being:

    error C2825: '_Fn2': must be a class or namespace when followed by '::'

    and the 2nd:

    error C2039: 'first_argument_type' : is not a member of '`global namespace''

    A Offline
    A Offline
    Aescleal
    wrote on last edited by
    #21

    Ooops, forgot to add in the bit of special sauce to convert the binary function pointer to a function object:

    std::transform( input.begin(), input.end(), output.begin(), std::bind2nd( std::ptr_fun( op_divide ), 5 ) ) );

    What you've got is a function that takes two arguments. The std::ptr_fun function returns a function object, the function call operator of which passes the arguments to the contained function. The std::bind2nd returns another function object: - the function call operator takes 1 parameter - the constructor of the object stores another parameter - the function call operator passes the 1 parameter and the stored parameter through to the contained binary function object which passes them through to the contained function pointer. Arrrgggghhhhh... I want me Lambda's back! Cheers, Ash PS: That's as clear as mud, I'll try and clean it up later

    B 1 Reply Last reply
    0
    • A Aescleal

      Ooops, forgot to add in the bit of special sauce to convert the binary function pointer to a function object:

      std::transform( input.begin(), input.end(), output.begin(), std::bind2nd( std::ptr_fun( op_divide ), 5 ) ) );

      What you've got is a function that takes two arguments. The std::ptr_fun function returns a function object, the function call operator of which passes the arguments to the contained function. The std::bind2nd returns another function object: - the function call operator takes 1 parameter - the constructor of the object stores another parameter - the function call operator passes the 1 parameter and the stored parameter through to the contained binary function object which passes them through to the contained function pointer. Arrrgggghhhhh... I want me Lambda's back! Cheers, Ash PS: That's as clear as mud, I'll try and clean it up later

      B Offline
      B Offline
      b rad311
      wrote on last edited by
      #22

      worked great, thanks Ash!

      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