Loading ...
Sorry, an error occurred while loading the content.

Re: [Boost-Users] Re: Does filter_iterator work for maps?

Expand Messages
  • Jeremy Siek
    On Fri, 15 Mar 2002, Jon Kalb wrote: kalb struct A kalb { kalb typedef kalb filter_iterator_generator ::iterator ::type kalb
    Message 1 of 9 , Mar 15, 2002
    • 0 Attachment
      On Fri, 15 Mar 2002, Jon Kalb wrote:
      kalb> > struct A
      kalb> > {
      kalb> > typedef
      kalb> > filter_iterator_generator<is_active,vector<int>::iterator>::type
      kalb> > active_iterator;
      kalb>
      kalb>
      kalb> CodeWarrior doesn't complain about this code, but I think that it should be:
      kalb>
      kalb> typedef typename
      kalb> filter_iterator_generator<is_active,vector<int>::iterator>::type
      kalb> active_iterator;

      "typename" is required when the type of the left-hand side of the "::" is
      somehow dependent on a template parameter, which is not the case in the
      above code.

      Also, "typename" is not allowed when the left-hand side is not dependent
      on a template paraemter, so adding "typename" to the above code results
      in an illegal program.

      Cheers,
      Jeremy

      ----------------------------------------------------------------------
      Jeremy Siek http://php.indiana.edu/~jsiek/
      Ph.D. Student, Indiana Univ. B'ton email: jsiek@...
      C++ Booster (http://www.boost.org) office phone: (812) 855-3608
      ----------------------------------------------------------------------
    • Jeremy Siek
      Hi Rodrigo, The above program compiles OK for me with g++ 2.95.2. What compiler are you using? (there s a good chance the compiler error you are getting is a
      Message 2 of 9 , Mar 15, 2002
      • 0 Attachment
        Hi Rodrigo,

        The above program compiles OK for me with g++ 2.95.2. What compiler are
        you using? (there's a good chance the compiler error you are getting is a
        bug in your compiler, not in your code or in the Boost code).

        Cheers,
        Jeremy

        On Sat, 16 Mar 2002, rodrigo_braz wrote:

        rodrig> --- In Boost-Users@y..., Jon Kalb <kalb@L...> wrote:
        rodrig> > At 3:01 AM +0000 3/15/02, rodrigo_braz wrote:
        rodrig> > > copy(boost::make_filter_iterator<pair_is_active>(m.begin, m.end
        rodrig> ()),
        rodrig> >
        rodrig> > copy(boost::make_filter_iterator<pair_is_active>(m.begin(), m.end
        rodrig> ()),
        rodrig>
        rodrig> Ouch. Ok, sorry about that. Actually my main problem with this
        rodrig> iterator is in the code below:
        rodrig>
        rodrig> #include <vector>
        rodrig> #include "boost/iterator_adaptors.hpp"
        rodrig>
        rodrig> using namespace std;
        rodrig> using namespace boost;
        rodrig>
        rodrig> struct is_active {
        rodrig> bool operator()(int p) { return 0 < p; }
        rodrig> };
        rodrig>
        rodrig> struct A
        rodrig> {
        rodrig> typedef
        rodrig> filter_iterator_generator<is_active,vector<int>::iterator>::type
        rodrig> active_iterator;
        rodrig> active_iterator i; // PROBLEM
        rodrig> };
        rodrig>
        rodrig> int main()
        rodrig> {
        rodrig> A a;
        rodrig> return 0;
        rodrig> }
        rodrig>
        rodrig> I get the error messages:
        rodrig>
        rodrig> 15: Type name expected
        rodrig> 15: Multiple declaration for 'A::active_iterator'
        rodrig> 14: Earlier declaration of 'A::active_iterator'
        rodrig> 15: Declaration missing ;
        rodrig>
        rodrig> Thanks,
        rodrig>
        rodrig> Rodrigo
        rodrig>
        rodrig>
        rodrig>
        rodrig>
        rodrig> Info: <http://www.boost.org>
        rodrig> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
        rodrig> Unsubscribe: <mailto:boost-users-unsubscribe@yahoogroups.com>
        rodrig>
        rodrig>
        rodrig> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        rodrig>
        rodrig>

        ----------------------------------------------------------------------
        Jeremy Siek http://php.indiana.edu/~jsiek/
        Ph.D. Student, Indiana Univ. B'ton email: jsiek@...
        C++ Booster (http://www.boost.org) office phone: (812) 855-3608
        ----------------------------------------------------------------------
      • Rodrigo de Salvo Braz
        ... _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
        Message 3 of 9 , Mar 16, 2002
        • 0 Attachment
          -----Mensagem original-----
          De: Jon Kalb <kalb@...>
          Para: Boost-Users@yahoogroups.com <Boost-Users@yahoogroups.com>
          Data: Sexta-feira, Março 15, 2002 09:01
          Assunto: Re: [Boost-Users] Re: Does filter_iterator work for maps?


          On 3/15/02 4:37 PM, "rodrigo_braz" <rodrigo_braz@...> wrote:

          >> Actually my main problem with this iterator is in the code below:


          >CodeWarrior doesn't complain about this code, but I think that it should be:

          As Jeremy pointed out, that doesn't work. It sounds like it is a compiler issue (I am using Borland). I will go back to the boost
          pages to see if there is anything I can do about it.

          Thanks,

          Rodrigo


          _________________________________________________________
          Do You Yahoo!?
          Get your free @... address at http://mail.yahoo.com
        • Rodrigo de Salvo Braz
          ... _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
          Message 4 of 9 , Mar 17, 2002
          • 0 Attachment
            -----Mensagem original-----
            De: Jeremy Siek <jsiek@...>


            >The above program compiles OK for me with g++ 2.95.2. What compiler are
            >you using? (there's a good chance the compiler error you are getting is a
            >bug in your compiler, not in your code or in the Boost code).


            Hi Jeremy,

            Thanks for the reply. Yes, I think it is the compiler too. I am using the Borland C++ Builder compiler 5.5 (the free command line
            compiler Borland made available a while ago). I am not sure yet I am not making a mistake, because I would expect this to be a
            popular compiler and simple things like this to have been found by now. All it takes to use the iterator adaptor libraries is
            including the header files, right?

            Thanks,

            Rodrigo


            _________________________________________________________
            Do You Yahoo!?
            Get your free @... address at http://mail.yahoo.com
          • Jeremy Siek
            Hi Rodrigo, To put it nicely, Borland is not one of the most standard compliant compilers. Even the free Gnu C++ is much better. I had to do a lot of
            Message 5 of 9 , Mar 17, 2002
            • 0 Attachment
              Hi Rodrigo,

              To put it nicely, Borland is not one of the most standard compliant
              compilers. Even the free Gnu C++ is much better. I had to do a lot of
              workarounds to get iterator adaptors working for Borland... and it sounds
              like there are still some problems. I suggest reporting this as a bug to
              Borland.

              Cheers,
              Jeremy

              On Sun, 17 Mar 2002, Rodrigo de Salvo Braz wrote:
              rodrig>
              rodrig> Hi Jeremy,
              rodrig>
              rodrig> Thanks for the reply. Yes, I think it is the compiler too.
              rodrig> I am using the Borland C++ Builder compiler 5.5 (the free
              rodrig> command line compiler Borland made available a while ago).
              rodrig> I am not sure yet I am not making a mistake, because I
              rodrig> would expect this to be a popular compiler and simple
              rodrig> things like this to have been found by now. All it takes
              rodrig> to use the iterator adaptor libraries is including the
              rodrig> header files, right?
              rodrig>
              rodrig> Thanks,
              rodrig>
              rodrig> Rodrigo


              ----------------------------------------------------------------------
              Jeremy Siek http://php.indiana.edu/~jsiek/
              Ph.D. Student, Indiana Univ. B'ton email: jsiek@...
              C++ Booster (http://www.boost.org) office phone: (812) 855-3608
              ----------------------------------------------------------------------
            Your message has been successfully submitted and would be delivered to recipients shortly.