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


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

Re: map[string_view] not compiling

From ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups comp.lang.c++
Subject Re: map[string_view] not compiling
Date 2022-08-01 12:57 +0000
Organization Stefan Ram
Message-ID <Convertibility-20220801135655@ram.dialup.fu-berlin.de> (permalink)
References <tc8epl$t0hn$1@dont-email.me> <jkpvfaF1b1gU1@mid.individual.net>

Show all headers | View raw


Bo Persson <bo@bo-persson.se> writes:
>Not an expert, but operator[] takes a Key parameter, which is 
>std::string here. And string_view is not implicitly convertible to 
>std::string.

  Even more not an expert, but I take it from the Web that
  even convertibililty alone would not suffice. The Web says:

|Three things are required for something like this to happen:
|
|1. The map's comparator must be a transparent comparator
|
|2. The at() method must have an overload that participates in
|   overload resolution when the container has a transparent
|   comparator.
|
|3. the parameter must be convertible to the map's key_type.
|
|Neither of these are true in your example. The default
|std::less comparator is not a transparent comparator, there
|is no such overload for at(), and std::string does not have
|an implicit conversion from std::string_view.
|
The World-Wide Web (2021).

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


csiph-web