boost::lambda start learning

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yurec

    boost::lambda start learning

    Hi
    I start learning boost.Today I tried to use boost::lambda but failed
    to compile very simple example.
    2 hours of googling gave nothing.
    Can anybody help me?

    using namespace boost::lambda;

    typedef std::map<int,st d::string_ttype ;
    type test;
    test[0] = (_T("1"));
    test[1] = (_T("2"));
    test[2] = (_T("3"));

    std::vector<std ::string_ttest_ vector;

    std::for_each(t est.begin(),tes t.end(),

    test_vector.pus h_back(bind(&ty pe::value_type: :second,_1))
    );

    ---------------------------------------------------------------------------------
    : error C2664: 'std::vector<_T y>::push_back' : cannot convert
    parameter 1 from 'const boost::lambda:: lambda_functor< T>' to 'const
    std::string_t &'

  • Victor Bazarov

    #2
    Re: boost::lambda start learning

    yurec wrote:
    I start learning boost.Today I tried to use boost::lambda but failed
    to compile very simple example.
    2 hours of googling gave nothing.
    Can anybody help me?
    >
    using namespace boost::lambda;
    >
    typedef std::map<int,st d::string_ttype ;
    I've never seen 'std::string_t' , what is is? There is no mention
    of 'string_t' in the Standard.
    type test;
    test[0] = (_T("1"));
    test[1] = (_T("2"));
    test[2] = (_T("3"));
    >
    std::vector<std ::string_ttest_ vector;
    >
    std::for_each(t est.begin(),tes t.end(),
    >
    test_vector.pus h_back(bind(&ty pe::value_type: :second,_1))
    );
    >
    ---------------------------------------------------------------------------------
    >error C2664: 'std::vector<_T y>::push_back' : cannot convert
    parameter 1 from 'const boost::lambda:: lambda_functor< T>' to 'const
    std::string_t &'
    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask


    Comment

    • =?iso-8859-1?q?Kirit_S=E6lensminde?=

      #3
      Re: boost::lambda start learning

      On Oct 30, 10:02 pm, yurec <Yurij.Zha...@m aterialise.kiev .uawrote:
      Hi
      I start learning boost.Today I tried to use boost::lambda but failed
      to compile very simple example.
      2 hours of googling gave nothing.
      Can anybody help me?
      >
      using namespace boost::lambda;
      >
      typedef std::map<int,st d::string_ttype ;
      type test;
      test[0] = (_T("1"));
      test[1] = (_T("2"));
      test[2] = (_T("3"));
      Microsoft's _T hack doesn't really address any of the important issues
      to do with going from narrow characters to wide characters. You're
      normally better off just using wide characters if you think you'll
      need them and narrow if you won't.
      >
      std::vector<std ::string_ttest_ vector;
      >
      std::for_each(t est.begin(),tes t.end(),
      >
      test_vector.pus h_back(bind(&ty pe::value_type: :second,_1))
      );
      You need to do a double bind. Although bind you have isn't really to a
      function, what you need to do is still function composition so you
      need a double bind - the first to bind to type::value_typ e::second and
      the second to bind to push_back.

      Take a look at this generic composition example: http://www.boostcookbook.com/Recipe:/1234820
      ---------------------------------------------------------------------------------
      : error C2664: 'std::vector<_T y>::push_back' : cannot convert
      parameter 1 from 'const boost::lambda:: lambda_functor< T>' to 'const
      std::string_t &'
      This is because you can't pass the functor you get from bind to
      push_back as you're doing. You need to also bind push_back.


      K

      Comment

      • Wade Ward

        #4
        Re: boost::lambda start learning


        "Kirit Sælensminde" <kirit.saelensm inde@gmail.comw rote in message
        news:1193801172 .814120.146730@ z9g2000hsf.goog legroups.com...
        On Oct 30, 10:02 pm, yurec <Yurij.Zha...@m aterialise.kiev .uawrote:
        >Hi
        >I start learning boost.Today I tried to use boost::lambda but failed
        >to compile very simple example.
        >2 hours of googling gave nothing.
        >Can anybody help me?
        >>
        >using namespace boost::lambda;
        >>
        > typedef std::map<int,st d::string_ttype ;
        > type test;
        > test[0] = (_T("1"));
        > test[1] = (_T("2"));
        > test[2] = (_T("3"));
        >
        Microsoft's _T hack doesn't really address any of the important issues
        to do with going from narrow characters to wide characters. You're
        normally better off just using wide characters if you think you'll
        need them and narrow if you won't.
        >
        >>
        > std::vector<std ::string_ttest_ vector;
        >>
        > std::for_each(t est.begin(),tes t.end(),
        >>
        >test_vector.pu sh_back(bind(&t ype::value_type ::second,_1))
        > );
        >
        You need to do a double bind. Although bind you have isn't really to a
        function, what you need to do is still function composition so you
        need a double bind - the first to bind to type::value_typ e::second and
        the second to bind to push_back.
        >
        Take a look at this generic composition example:

        >
        >---------------------------------------------------------------------------------
        >: error C2664: 'std::vector<_T y>::push_back' : cannot convert
        >parameter 1 from 'const boost::lambda:: lambda_functor< T>' to 'const
        >std::string_ t &'
        >
        This is because you can't pass the functor you get from bind to
        push_back as you're doing. You need to also bind push_back.
        so nice to see. work along these lines that isn't mine.

        Is it possible that c++ understands what a functor is?

        --
        wade ward

        President
        Merrill Jensen Consulting


        wade@zaxfuuq.ne t
        435 -838-7760


        Comment

        • yurec

          #5
          Re: boost::lambda start learning

          On 31 , 06:45, "Wade Ward" <zaxf...@invali d.netwrote:
          "Kirit Sælensminde" <kirit.saelensm i...@gmail.comw rote in message
          >
          news:1193801172 .814120.146730@ z9g2000hsf.goog legroups.com...
          >
          On Oct 30, 10:02 pm, yurec <Yurij.Zha...@m aterialise.kiev .uawrote:
          Hi
          I start learning boost.Today I tried to use boost::lambda but failed
          to compile very simple example.
          2 hours of googling gave nothing.
          Can anybody help me?
          >
          using namespace boost::lambda;
          >
          typedef std::map<int,st d::string_ttype ;
          type test;
          test[0] = (_T("1"));
          test[1] = (_T("2"));
          test[2] = (_T("3"));
          >
          Microsoft's _T hack doesn't really address any of the important issues
          to do with going from narrow characters to wide characters. You're
          normally better off just using wide characters if you think you'll
          need them and narrow if you won't.
          >
          std::vector<std ::string_ttest_ vector;
          >
          std::for_each(t est.begin(),tes t.end(),
          >
          test_vector.pus h_back(bind(&ty pe::value_type: :second,_1))
          );
          >
          You need to do a double bind. Although bind you have isn't really to a
          function, what you need to do is still function composition so you
          need a double bind - the first to bind to type::value_typ e::second and
          the second to bind to push_back.
          >
          Take a look at this generic composition example:
          http://www.boostcookbook.com/Recipe:/1234820
          >
          ---------------------------------------------------------------------------­------
          : error C2664: 'std::vector<_T y>::push_back' : cannot convert
          parameter 1 from 'const boost::lambda:: lambda_functor< T>' to 'const
          std::string_t &'
          >
          This is because you can't pass the functor you get from bind to
          push_back as you're doing. You need to also bind push_back.
          >
          so nice to see. work along these lines that isn't mine.
          >
          Is it possible that c++ understands what a functor is?
          >
          --
          wade ward
          >
          President
          Merrill Jensen Consulting
          >
          w...@zaxfuuq.ne t
          435 -838-7760
          Ok, thanks to everybody, I work with it a little more , understand
          better and now everyting is ok.

          Comment

          Working...