Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #72243 > unrolled thread

Structured binding considered harmful

Started byjacobnavia <jacob@jacob.remcomp.fr>
First post2020-03-13 00:13 +0100
Last post2020-03-21 01:43 -0700
Articles 20 on this page of 122 — 17 participants

Back to article view | Back to comp.lang.c++


Contents

  Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-13 00:13 +0100
    Re: Structured binding considered harmful Maciej Sobczak <see.my.homepage@gmail.com> - 2020-03-13 00:46 -0700
      Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-14 09:10 +0100
    Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-13 09:40 -0700
      Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-14 09:05 +0100
        Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-14 03:19 -0700
          Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-15 11:08 +0000
            Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-15 09:46 -0700
              Re: Structured binding considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-03-15 19:27 +0100
                Re: Structured binding considered harmful Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-03-15 15:15 -0700
                  Re: Structured binding considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-03-16 05:23 +0100
                    Re: Structured binding considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-03-16 05:54 +0100
                Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-16 00:20 -0700
    Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-13 23:08 -0400
      Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-14 08:59 +0100
        Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-14 10:09 -0400
          Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-14 18:32 +0100
            Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-14 18:33 -0400
    Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-15 17:50 +0100
      Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-16 00:11 +0100
        Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-16 05:24 +0100
          Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-16 06:46 -0400
            Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-16 12:52 +0100
              Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-16 08:32 -0400
                Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-16 13:51 +0100
                  Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-16 20:06 -0400
                    Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-17 06:37 +0100
                      Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-17 07:17 -0400
                        Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-17 18:37 +0100
                          Re: Structured binding considered harmful "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-03-17 18:50 +0100
                          Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 06:30 -0400
                            Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 11:38 +0100
                              Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 08:17 -0400
                                Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 13:19 +0100
                                  Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 08:31 -0400
                                    Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 14:15 +0100
                                      Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 10:13 -0400
                                        Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 15:45 +0100
                                          Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 11:36 -0400
                                            Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 17:59 +0100
                                              Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 13:18 -0400
                                                Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 18:27 +0100
                                                  Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 14:41 -0400
                                                    Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 19:46 +0100
                                                      Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 19:46 -0400
                                                        Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-19 06:41 +0100
                                                          Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-19 07:02 -0400
                                                            Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-19 12:41 +0100
                                                              Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-19 06:10 -0700
                                                                Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-19 14:15 +0100
                                                              Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-19 19:23 -0400
                                                                Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-20 09:18 +0100
                                                                  Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-20 05:31 -0700
                                                                    Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-20 13:40 +0100
                                                                      Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-20 08:50 -0700
                                                                        Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 09:30 -0700
                                                                          Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-20 10:13 -0700
                                                                            Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 10:36 -0700
                                                                              Re: Structured binding considered harmful Ian Collins <ian-news@hotmail.com> - 2020-03-21 12:06 +1300
                                                                              Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-20 16:37 -0700
                                                                                Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 17:17 -0700
                                                                                  Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-21 10:09 -0700
                                                                                    Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 11:21 -0700
                                                                                      Re: Structured binding considered harmful Öö Tiib <ootiib@hot.ee> - 2020-03-21 13:09 -0700
                                                                                        Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-21 22:33 +0000
                                                                          Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-20 17:30 +0000
                                                                            Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 10:49 -0700
                                                                              Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-20 18:47 +0000
                                                                        Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-20 17:41 +0100
                                                                          Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-20 18:06 -0400
                                                                            Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-21 06:31 +0100
                                                                              Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 09:50 -0400
                                                                                Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-21 14:59 +0100
                                                                                  Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 10:42 -0400
                                                                                    Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-21 16:09 +0100
                                                                                      Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 11:12 -0400
                                                                      Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-20 18:05 -0400
                                                                        Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-20 15:57 -0700
                                                                          Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-20 23:23 -0400
                                                                            Re: Structured binding considered harmful Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-03-20 21:08 -0700
                                                                            Re: Structured binding considered harmful Ralf Goertz <me@myprovider.invalid> - 2020-03-21 08:24 +0100
                                                                            Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 01:36 -0700
                                                                        Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-21 06:30 +0100
                                                                          Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 09:51 -0400
                                                                            Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-22 13:22 +0100
                                                                              Re: Structured binding considered harmful Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-03-22 13:24 +0000
                                                                              Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-22 06:32 -0700
                                                                                Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-22 07:59 -0700
                                                                                  Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 13:02 -0400
                                                                                    Re: Structured binding considered harmful Melzzzzz <Melzzzzz@zzzzz.com> - 2020-03-22 17:09 +0000
                                                                                      Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 13:35 -0400
                                                                                        Re: Structured binding considered harmful Melzzzzz <Melzzzzz@zzzzz.com> - 2020-03-22 17:54 +0000
                                                                                          Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 17:19 -0400
                                                                                            Re: Structured binding considered harmful Melzzzzz <Melzzzzz@zzzzz.com> - 2020-03-22 21:46 +0000
                                                                                              Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 19:06 -0400
                                                                                                Re: Structured binding considered harmful danielaparker@gmail.com - 2020-03-22 17:11 -0700
                                                                                                  Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 22:16 -0400
                                                                                                  Re: Structured binding considered harmful Chris Vine <chris@cvine--nospam--.freeserve.co.uk> - 2020-03-25 20:38 +0000
                                                                                                    Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-25 20:01 -0400
                                                                                      Re: Structured binding considered harmful danielaparker@gmail.com - 2020-03-22 10:58 -0700
                                                                                  Re: Structured binding considered harmful Ian Collins <ian-news@hotmail.com> - 2020-03-23 07:41 +1300
                                                                                  Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-22 15:01 -0400
                                                                              Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-22 10:24 -0400
                                                                      Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-20 20:15 -0700
                                                                        Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-21 08:32 +0100
                                                                          Re: Structured binding considered harmful David Brown <david.brown@hesbynett.no> - 2020-03-21 11:27 +0100
                                                                            Re: Structured binding considered harmful Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2020-03-21 13:34 +0000
                                                                            Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 07:11 -0700
                                                                              Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-21 10:45 -0400
                                                                                Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 08:03 -0700
                                                            Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-19 08:24 -0700
                                                    Re: Structured binding considered harmful Ian Collins <ian-news@hotmail.com> - 2020-03-19 09:05 +1300
                                                      Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-18 19:47 -0400
                                              Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-18 11:43 -0700
                                                Re: Structured binding considered harmful Bonita Montero <Bonita.Montero@gmail.com> - 2020-03-18 19:48 +0100
                                                  Re: Structured binding considered harmful James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-03-18 12:37 -0700
            Re: Structured binding considered harmful jacobnavia <jacob@jacob.remcomp.fr> - 2020-03-16 16:11 +0100
              Re: Structured binding considered harmful Ian Collins <ian-news@hotmail.com> - 2020-03-17 08:17 +1300
              Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-16 13:12 -0700
              Re: Structured binding considered harmful Sam <sam@email-scan.com> - 2020-03-16 20:13 -0400
    Re: Structured binding considered harmful Melzzzzz <Melzzzzz@zzzzz.com> - 2020-03-17 19:46 +0000
      Re: Structured binding considered harmful Daniel <danielaparker@gmail.com> - 2020-03-21 01:43 -0700

Page 4 of 7 — ← Prev page 1 2 3 [4] 5 6 7  Next page →


#72430

FromDaniel <danielaparker@gmail.com>
Date2020-03-20 17:17 -0700
Message-ID<3ae246b8-7e22-46d0-a1c2-afce4448cd8a@googlegroups.com>
In reply to#72429
On Friday, March 20, 2020 at 7:37:25 PM UTC-4, Öö Tiib wrote:
> On Friday, 20 March 2020 19:36:35 UTC+2, Daniel  wrote:

> > 
> > I would use "it", for a local iterator variable :-) Also i/j/k for indices.
> 
> Good idea, "it" instead of "iter" saves whole whopping 2 characters from:
> 
>     std::vector<std::pair<std::string, int>>::const_iterator it 
>                = container.begin();
> 
Personally, I would use

    auto it = container.begin();

(I'm reading a lot of rust code these days, where the convention is to use
very short names.)

> Ironically from "auto e" I would at least know that it is copy. 

Yes, but a copy of what? In the case of a proxied container, that would be
a copy of a proxy, which you probably wouldn't want. A proxy cannot be safely assumed to have a life longer than a single statement.

Daniel

[toc] | [prev] | [next] | [standalone]


#72451

FromÖö Tiib <ootiib@hot.ee>
Date2020-03-21 10:09 -0700
Message-ID<f38c745f-b6cf-4a7b-b8e1-c714944c16d8@googlegroups.com>
In reply to#72430
On Saturday, 21 March 2020 02:17:22 UTC+2, Daniel  wrote:
> On Friday, March 20, 2020 at 7:37:25 PM UTC-4, Öö Tiib wrote:
> > On Friday, 20 March 2020 19:36:35 UTC+2, Daniel  wrote:
> 
> > > 
> > > I would use "it", for a local iterator variable :-) Also i/j/k for indices.
> > 
> > Good idea, "it" instead of "iter" saves whole whopping 2 characters from:
> > 
> >     std::vector<std::pair<std::string, int>>::const_iterator it 
> >                = container.begin();
> > 
> Personally, I would use
> 
>     auto it = container.begin();

And I don't use neither "it" nor "container" for name of anything. 

> (I'm reading a lot of rust code these days, where the convention is to use
> very short names.)

Perhaps people are translating their legacy algorithms from FORTRAN to see
how it performs.

> > Ironically from "auto e" I would at least know that it is copy. 
> 
> Yes, but a copy of what? In the case of a proxied container, that would be
> a copy of a proxy, which you probably wouldn't want. A proxy cannot be safely assumed to have a life longer than a single statement.

I do not have nor use peroxided containers. Several tools warn me about
std::vector<bool> usage. It is not container nor does it contain bools.
Such things are worse than raw pointers that at least lack bloat.
You use it? Maybe you overload operator,() and unary operator&() as
well ... I don't and my tools warn about lot of such usage of nuisance
language features that should not be there at first place.

[toc] | [prev] | [next] | [standalone]


#72452

FromDaniel <danielaparker@gmail.com>
Date2020-03-21 11:21 -0700
Message-ID<49edec1c-12d8-410a-9f03-7205cd7bc404@googlegroups.com>
In reply to#72451
On Saturday, March 21, 2020 at 1:09:21 PM UTC-4, Öö Tiib wrote:
> 
> And I don't use neither "it" ...
> 
> people are translating their legacy algorithms from FORTRAN ...
> 
> I do not have nor use peroxided containers ...

> Maybe you overload operator,() and unary operator&() as well ... 

I'm sorry if my post has made you angry and upset. I don't know how to 
respond to any of your statements above. My point was narrow, and fully
expostulated in my other posts.

Best regards,
Daniel

[toc] | [prev] | [next] | [standalone]


#72455

FromÖö Tiib <ootiib@hot.ee>
Date2020-03-21 13:09 -0700
Message-ID<5e4b6ae3-ecd1-4a2b-8721-4786302a6965@googlegroups.com>
In reply to#72452
On Saturday, 21 March 2020 20:21:30 UTC+2, Daniel  wrote:
> On Saturday, March 21, 2020 at 1:09:21 PM UTC-4, Öö Tiib wrote:
> > 
> > And I don't use neither "it" ...
> > 
> > people are translating their legacy algorithms from FORTRAN ...
> > 
> > I do not have nor use peroxided containers ...
> 
> > Maybe you overload operator,() and unary operator&() as well ... 
> 
> I'm sorry if my post has made you angry and upset. I don't know how to 
> respond to any of your statements above. My point was narrow, and fully
> expostulated in my other posts.

Nah, don't be sorry. It is not you. It is just me being grumpy lately
because of miles of such code to help with. For whatever reasons
people prefer to abuse tools. So there is auto, lets split into 
two schools, one that tries to overuse it and other that tries to
avoid it entirely. Then let members of both schools to work over same
code-base. Same about naming either use one letter names or over
30 letter names. Raw pointers are dangerous? Ok, lets make everything that
god damned shared_ptr. Can make sub-repositories? So lets make hundred
of those for every taste but lets make one or two of those huge. And be
sure to arrange those sub-repositories as directed graph with cycles. 

[toc] | [prev] | [next] | [standalone]


#72457

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2020-03-21 22:33 +0000
Message-ID<slrnr7d5h2.1r7q.grahn+nntp@frailea.sa.invalid>
In reply to#72455
On Sat, 2020-03-21, Öö Tiib wrote:
...
> Nah, don't be sorry. It is not you. It is just me being grumpy lately
> because of miles of such code to help with. For whatever reasons
> people prefer to abuse tools. So there is auto, lets split into 
> two schools, one that tries to overuse it and other that tries to
> avoid it entirely. Then let members of both schools to work over same
> code-base. Same about naming either use one letter names or over
> 30 letter names. Raw pointers are dangerous? Ok, lets make everything that
> god damned shared_ptr. Can make sub-repositories? So lets make hundred
> of those for every taste but lets make one or two of those huge. And be
> sure to arrange those sub-repositories as directed graph with cycles. 

You may be interested to hear that I laughed out loud when
I read that. :-)

I know exactly what you mean, and it is depressing ... but it's kind
of funny, too.

The software company or project that can overcome that (both the "two
camps" thing and the "more extreme is always better" thing) would be
in a very good position.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [next] | [standalone]


#72421

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2020-03-20 17:30 +0000
Message-ID<slrnr79vd2.1r7q.grahn+nntp@frailea.sa.invalid>
In reply to#72418
On Fri, 2020-03-20, Daniel wrote:
...
> Nonetheless, Bonita's point, that while usually not necessary to know the 
> exact type, sometime it is, is valid. Looking only at
>
>     for (const auto &v:container)
>     {
>
> without knowing more about the container, it is not possible to know 
> by inspection whether type deduction rules via auto will do the right
> thing. 

Do you have any examples of containers where that doesn't do the right
thing?  (Assuming the loop just wants to visit the elements in
sequence, and not try to modify 'container' or anything.)

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [next] | [standalone]


#72423

FromDaniel <danielaparker@gmail.com>
Date2020-03-20 10:49 -0700
Message-ID<bdee6e01-0fde-4747-b515-c5ac493cbbe1@googlegroups.com>
In reply to#72421
On Friday, March 20, 2020 at 1:30:23 PM UTC-4, Jorgen Grahn wrote:
> 
> Do you have any examples of containers where that doesn't do the right
> thing?  (Assuming the loop just wants to visit the elements in
> sequence, and not try to modify 'container' or anything.)
> 
A trivial example is

#include <vector>
#include <iostream>

void f(bool)
{
    std::cout << "bool!\n";
}

template <class T>
void f(T)
{
    std::cout << "not bool!\n";
}

int main()
{
    std::vector<bool> v = { true,false };

    for (const auto& item : v)
    {
        f(item);
    }
}

Output:

not bool!
not bool!

More generally, with proxied containers, all bets are off, think expression 
templates or lazy initialization.

Daniel

[toc] | [prev] | [next] | [standalone]


#72424

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2020-03-20 18:47 +0000
Message-ID<slrnr7a3ts.1r7q.grahn+nntp@frailea.sa.invalid>
In reply to#72423
On Fri, 2020-03-20, Daniel wrote:
> On Friday, March 20, 2020 at 1:30:23 PM UTC-4, Jorgen Grahn wrote:
>> 
>> Do you have any examples of containers where that doesn't do the right
>> thing?  (Assuming the loop just wants to visit the elements in
>> sequence, and not try to modify 'container' or anything.)

...
>     std::vector<bool>
...
> More generally, with proxied containers, all bets are off, think expression 
> templates or lazy initialization.

Ah, thanks.  I don't think I've ever seen any of those in the wild.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .     .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [next] | [standalone]


#72419

FromBonita Montero <Bonita.Montero@gmail.com>
Date2020-03-20 17:41 +0100
Message-ID<r52rnb$8ec$1@news.albasani.net>
In reply to#72417
>>> If know  C++, you often don't need to know the exact type, and
>>> therefore don't need to read the part where the container was
>>> defined or declared. That's particularly true if, as specified,
>>> the code was well-written.

>> Usually not.

> We have indeed seen that your code is usually not well written,
> but ... it is not fault of ours. Try harder?

It doesn't depend on how good the code is written. You would have to
have a crystal bulb to guess the type auto refers to in this case.

[toc] | [prev] | [next] | [standalone]


#72426

FromSam <sam@email-scan.com>
Date2020-03-20 18:06 -0400
Message-ID<cone.1584741985.221169.180278.1004@monster.email-scan.com>
In reply to#72419

[Multipart message — attachments visible in raw view] — view raw

Bonita Montero writes:

>>>> If know  C++, you often don't need to know the exact type, and
>>>> therefore don't need to read the part where the container was
>>>> defined or declared. That's particularly true if, as specified,
>>>> the code was well-written.
>
>>> Usually not.
>
>> We have indeed seen that your code is usually not well written,
>> but ... it is not fault of ours. Try harder?
>
> It doesn't depend on how good the code is written. You would have to
> have a crystal bulb to guess the type auto refers to in this case.

No, the type it refers to is very obvious.

[toc] | [prev] | [next] | [standalone]


#72435

FromBonita Montero <Bonita.Montero@gmail.com>
Date2020-03-21 06:31 +0100
Message-ID<r548r8$q80$2@news.albasani.net>
In reply to#72426
>> It doesn't depend on how good the code is written. You would have to
>> have a crystal bulb to guess the type auto refers to in this case.

> No, the type it refers to is very obvious.

... if you know the type of the container.

[toc] | [prev] | [next] | [standalone]


#72442

FromSam <sam@email-scan.com>
Date2020-03-21 09:50 -0400
Message-ID<cone.1584798638.697338.194011.1004@monster.email-scan.com>
In reply to#72435

[Multipart message — attachments visible in raw view] — view raw

Bonita Montero writes:

>>> It doesn't depend on how good the code is written. You would have to
>>> have a crystal bulb to guess the type auto refers to in this case.
>
>> No, the type it refers to is very obvious.
>
> ... if you know the type of the container.

A real C++ developer doesn't need to know the type of a container in order  
to implement well-defined algorithms.

You better everyone who writes template code that what they're doing is  
impossible. They're writing code that operates on templates whose type they  
don't know, after all.

[toc] | [prev] | [next] | [standalone]


#72444

FromBonita Montero <Bonita.Montero@gmail.com>
Date2020-03-21 14:59 +0100
Message-ID<r556kq$otq$1@news.albasani.net>
In reply to#72442
> You better everyone who writes template code that what they're doing is 
> impossible. They're writing code that operates on templates whose type 
> they don't know, after all.

Usually the container isn't a template-parameter itself so you know
the type of the container.

[toc] | [prev] | [next] | [standalone]


#72446

FromSam <sam@email-scan.com>
Date2020-03-21 10:42 -0400
Message-ID<cone.1584801764.926599.3850.1004@monster.email-scan.com>
In reply to#72444

[Multipart message — attachments visible in raw view] — view raw

Bonita Montero writes:

>> You better everyone who writes template code that what they're doing is  
>> impossible. They're writing code that operates on templates whose type they  
>> don't know, after all.
>
> Usually the container isn't a template-parameter itself so you know
> the type of the container.

Completely wrong, you're just not very experienced with template  
metaprogramming.

[toc] | [prev] | [next] | [standalone]


#72449

FromBonita Montero <Bonita.Montero@gmail.com>
Date2020-03-21 16:09 +0100
Message-ID<r55amg$gr5$1@news.albasani.net>
In reply to#72446
>> Usually the container isn't a template-parameter itself so you know
>> the type of the container.

> Completely wrong, you're just not very experienced with template 
> metaprogramming.

You didn't understand what I wrote.

[toc] | [prev] | [next] | [standalone]


#72450

FromSam <sam@email-scan.com>
Date2020-03-21 11:12 -0400
Message-ID<cone.1584803542.996973.3850.1004@monster.email-scan.com>
In reply to#72449

[Multipart message — attachments visible in raw view] — view raw

Bonita Montero writes:

>>> Usually the container isn't a template-parameter itself so you know
>>> the type of the container.
>
>> Completely wrong, you're just not very experienced with template  
>> metaprogramming.
>
> You didn't understand what I wrote.

Only the voices in your head understand what you write.

[toc] | [prev] | [next] | [standalone]


#72425

FromSam <sam@email-scan.com>
Date2020-03-20 18:05 -0400
Message-ID<cone.1584741905.87390.180278.1004@monster.email-scan.com>
In reply to#72416

[Multipart message — attachments visible in raw view] — view raw

Bonita Montero writes:

>> If know  C++, you often don't need to know the exact type, and
>> therefore don't need to read the part where the container was
>> defined or declared. ...
>
> Usually not.

In your case, definitely. But not in the case of those who have above- 
average C++ skills and experience.

[toc] | [prev] | [next] | [standalone]


#72427

FromDaniel <danielaparker@gmail.com>
Date2020-03-20 15:57 -0700
Message-ID<2b196b3d-f376-4bb4-a05c-bfa3d5160403@googlegroups.com>
In reply to#72425
On Friday, March 20, 2020 at 6:05:17 PM UTC-4, Sam wrote:
> 
> In your case, definitely. But not in the case of those who have above- 
> average C++ skills and experience.

Bm7    | E7 |
He's Trolling
 G                     F#m7
And he hopes you like trolling too

[toc] | [prev] | [next] | [standalone]


#72432

FromSam <sam@email-scan.com>
Date2020-03-20 23:23 -0400
Message-ID<cone.1584761010.587835.185377.1004@monster.email-scan.com>
In reply to#72427

[Multipart message — attachments visible in raw view] — view raw

Daniel writes:

> On Friday, March 20, 2020 at 6:05:17 PM UTC-4, Sam wrote:
> >
> > In your case, definitely. But not in the case of those who have above-
> > average C++ skills and experience.
>
> Bm7    | E7 |

Some kind of a secret code?

> He's Trolling
>  G                     F#m7

I misplaced my secret decoder ring, so this won't work for me.

> And he hopes you like trolling too

Well, all the available evidence suggests that I've been trolling, off and  
on, since he/she/it was in diapers. The only major difference is that I only  
troll the trollers.


[toc] | [prev] | [next] | [standalone]


#72433

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2020-03-20 21:08 -0700
Message-ID<87lfnuqrir.fsf@nosuchdomain.example.com>
In reply to#72432
Sam <sam@email-scan.com> writes:
[...]
> Well, all the available evidence suggests that I've been trolling, off
> and on, since he/she/it was in diapers. The only major difference is
> that I only troll the trollers.

No, when you post on a public newsgroup you troll all of us.

If you feed the troll, you are a troll.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


Page 4 of 7 — ← Prev page 1 2 3 [4] 5 6 7  Next page →

Back to top | Article view | comp.lang.c++


csiph-web