Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6129459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:44:42+00:00 2026-05-23T16:44:42+00:00

I’m working on a proof of concept here for a zip iterator that conforms

  • 0

I’m working on a proof of concept here for a zip iterator that conforms to STL algorithms. const correctness is incomplete and it could definitely be made much better, but it works for std::for_each, std::upper_bound and std::lower_bound. That is until I replace it with tr1::bind. At that point I fail to compile with numerous template errors. I’ve included the code below, but I have no idea how to trace this down. Any help is appreciated.

Container class

#pragma once

#include <vector>

class Container
{
public:
    class ZippedInfo
    {
    public:
        ZippedInfo(int& pos, Container* cont):
            m_pos(pos), 
            m_cont(cont)
            {};

        double& Bar(){ return m_cont->Bar(m_pos);}

        double& Foo(){ return m_cont->Foo(m_pos);}
    private:
        int& m_pos;
        Container* m_cont;
    };

    class iterator : public std::iterator<std::random_access_iterator_tag, ZippedInfo> 
    {
    public:
        iterator(int pos, Container* cont):
          m_Pos(pos), 
          m_Container(cont),
          m_ZippedInfo(m_Pos, cont)
          {}

          iterator():
              m_Pos(0), 
              m_Container(nullptr),
              m_ZippedInfo(m_Pos, nullptr)
          {}


        iterator(const iterator& rhs):
          m_Pos(rhs.m_Pos),
          m_Container(rhs.m_Container),
          m_ZippedInfo(m_Pos, rhs.m_Container)
        {}  

        ZippedInfo& operator*() {return m_ZippedInfo;}

        iterator& operator=(const iterator& rhs)
        {
            m_Container = rhs.m_Container;
            m_Pos = rhs.m_Pos;
            return *this;
        }

        iterator& operator += (int increment)
        {
            m_Pos += increment;
            return *this;
        }

        bool operator !=(const iterator& rhs)
        {
            return !(operator==(rhs));
        }

        bool operator ==(const iterator& rhs)
        {
            return m_Container == rhs.m_Container && m_Pos == rhs.m_Pos;
        }

        iterator& operator++()
        {
            m_Pos++;
            return *this;
        }

        int operator -(const iterator& rhs)
        {
            return m_Pos - rhs.m_Pos;
        }

        bool operator < (const iterator& rhs)
        {
            return m_Pos < rhs.m_Pos;
        }
    private:
        int m_Pos;
        ZippedInfo m_ZippedInfo;
        Container* m_Container;
    };

    Container() {}
    Container(const std::vector<double> &bar, const std::vector<double>& foo):
        m_bar(bar),
        m_foo(foo)
    {   }


    iterator begin()
    {
        return iterator(0, this);
    }

    iterator end()
    {
        return iterator(m_foo.size(), this);
    }

    double& Foo(int index){return m_foo[index];}
    double& Bar(int index){return m_bar[index];}
private:
    std::vector<double> m_foo;
    std::vector<double> m_bar;
};

Main program

#include "stdafx.h"
#include <algorithm>
#include <iostream>
#include <string>
#include <functional>
#include <boost\bind.hpp>
#include "test_iter.h"

using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
    vector<double> foo;
    foo.push_back(1);
    foo.push_back(2);
    foo.push_back(3);
    foo.push_back(4);
    foo.push_back(5);

    vector<double>bar;
    bar.push_back(1);
    bar.push_back(3);
    bar.push_back(5);
    bar.push_back(7);
    bar.push_back(9);

    Container c(bar, foo);

    double searchnum = 3;


    /*Container::iterator cf_iter3 = std::lower_bound(c.begin(), 
                                        c.end(), 
                                        searchnum,
                                        std::tr1::bind(&Container::ZippedInfo::Bar, std::tr1::placeholders::_1) < searchnum );*/

    Container::iterator cf_iter2 = std::lower_bound(c.begin(), 
                                        c.end(), 
                                        searchnum,
                                        boost::bind(&Container::ZippedInfo::Bar, _1) < searchnum );

    cout << (*cf_iter2).Bar() << endl;

The boost version works, the tr1 version gives the following errors

error C2065: 'cf_iter' : undeclared identifier
error C2228: left of '.Bar' must have class/struct/union
error C2676: binary '<' : 'std::tr1::_Bind<_Result_type,_Ret,_BindN>' does not define this operator or a conversion to a type acceptable to the predefined operator
error C2780: '_FwdIt std::lower_bound(_FwdIt,_FwdIt,const _Ty &)' : expects 3 arguments - 4 provided
error C2784: 'bool std::operator <(const _Elem *,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const _Elem *' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const _Elem *)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::basic_string<_Elem,_Traits,_Alloc> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'const std::basic_string<_Elem,_Traits,_Alloc> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::tr1::operator <(const std::tr1::shared_ptr<_Ty> &,const std::tr1::shared_ptr<_Ty2> &)' : could not deduce template argument for 'const std::tr1::shared_ptr<_Ty> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
error C2784: 'bool std::tr1::operator <(const std::tr1::shared_ptr<_Ty> &,const std::tr1::shared_ptr<_Ty2> &)' : could not deduce template argument for 'const std::tr1::shared_ptr<_Ty> &' from 'std::tr1::_Bind<_Result_type,_Ret,_BindN>'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:44:43+00:00Added an answer on May 23, 2026 at 4:44 pm

    Talking about C++0x here, make the suitable adaptations for TR1 if you please.

    std::bind differs from boost::bind in that it does not provide convenience overloads for operators. Using the documentation, we can build the standard replacement:

    Container::iterator cf_iter3 = std::lower_bound(c.begin(), c.end(), searchnum,
       std::bind(std::less<double>(),
                 std::bind(&Container::ZippedInfo::Bar, std::placeholders::_1),
                 searchnum)
                                                   );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.