Problem with Binders

This is a discussion on Problem with Binders within the C++ Programming forums, part of the General Programming Boards category; Hi, I am working with STL and found a problem with using binders. The code I am using is as ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    104

    Problem with Binders

    Hi,

    I am working with STL and found a problem with using binders.

    The code I am using is as follow:

    Code:
    #include <iostream>
    #include <functional>
    #include <vector>
    #include <algorithm>
    using namespace std;
    
    
    int main()
    {
         vector<string> vecstr;
    
         vecstr.push_back("aaaa");
         vecstr.push_back("bbbb");
         vecstr.push_back("zzzz");
         vecstr.push_back("bbbb");
    
    int d = ( int ) count_if(vecstr.begin(), vecstr.end(), bind1st(equal_to(),"bbbb") );
    cout << "\n d = " << d << endl;
    
    }
    It's giving me error :
    binder.cpp:17: error: missing template arguments before Ď(í token
    I have copy this example from net to learn Binders.

    Thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,456
    You need to provide the template argument to equal_to:
    Code:
    int d = count_if(vecstr.begin(), vecstr.end(), bind1st(equal_to<string>(), "bbbb"));
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    104
    Thanks for help !

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21