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


Groups > comp.lang.c++ > #120608

Lambda in STL compare

From Muttley@DastartdlyHQ.org
Newsgroups comp.lang.c++
Subject Lambda in STL compare
Date 2024-10-07 07:32 +0000
Organization A noiseless patient Spider
Message-ID <ve02pi$1kp91$1@dont-email.me> (permalink)

Show all headers | View raw


Isn't it about time that lambda functions could be used directly as STL
comparitors instead of it being an ugly 2 step process? 

ie instead of:

auto comp = [](const string &s1, const string &s2)
{
	return strcasecmp(s1.c_str(),s2.c_str()) < 0;
};
map<string,int,decltype(comp)> m(comp);

which is no simpler than just using a functor, why can't we just do:

map<string,int,[](const string &s1, const string &s2)
{
        return strcasecmp(s1.c_str(),s2.c_str()) < 0;
}) m;

I'm sure updating the compilers so a lambda could be a template parameter 
wouldn't be beyond the wit of man.

Rather than adding esoteric functionality no one uses wouldn't it be better
to tidy up what there is already?

Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-07 07:32 +0000
  Re: Lambda in STL compare Bonita Montero <Bonita.Montero@gmail.com> - 2024-10-07 10:12 +0200
    Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-07 09:32 +0000
  Re: Lambda in STL compare David Brown <david.brown@hesbynett.no> - 2024-10-07 10:16 +0200
  Re: Lambda in STL compare Sam <sam@email-scan.com> - 2024-10-07 07:35 -0400
    Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-07 14:06 +0000
      Re: Lambda in STL compare Bonita Montero <Bonita.Montero@gmail.com> - 2024-10-07 16:13 +0200
        Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-07 14:53 +0000
          Re: Lambda in STL compare Bonita Montero <Bonita.Montero@gmail.com> - 2024-10-07 17:06 +0200
            Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-07 15:46 +0000
              Re: Lambda in STL compare Bonita Montero <Bonita.Montero@gmail.com> - 2024-10-07 17:55 +0200
                Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-08 08:23 +0000
                Re: Lambda in STL compare Bonita Montero <Bonita.Montero@gmail.com> - 2024-10-08 10:25 +0200
                Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-08 10:24 +0000
                Re: Lambda in STL compare Bonita Montero <Bonita.Montero@gmail.com> - 2024-10-08 13:10 +0200
      Re: Lambda in STL compare Sam <sam@email-scan.com> - 2024-10-08 08:25 -0400
        Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-08 14:44 +0000
          Re: Lambda in STL compare Sam <sam@email-scan.com> - 2024-10-08 17:52 -0400
            Re: Lambda in STL compare "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-08 22:56 -0700
            Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-09 07:15 +0000
              Re: Lambda in STL compare Bonita Montero <Bonita.Montero@gmail.com> - 2024-10-09 09:21 +0200
                Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-09 07:22 +0000
            Re: Lambda in STL compare Muttley@DastartdlyHQ.org - 2024-10-09 07:16 +0000
              Re: Lambda in STL compare "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-10-09 00:23 -0700
  Re: Lambda in STL compare Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-10-07 07:17 -0700

csiph-web