March 29, 2005 A use case for string_view | ||||
---|---|---|---|---|
| ||||
Here's what I think is an interesting use case for string_view: <code> class named_class { string name const(); // ... other properties }; typedef std::map<string_view,named_class> container; </code> Replacing what could've been: - map<string,named_class> duplicating name values - vector<named_class> having to mantain element order manually - vector<named_class> with linear searching using the string_view, you can take advantage of map's functionality, without paying for duplicated name strings Just a thought... Pablo |
April 05, 2005 Re: A use case for string_view | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pablo Aguilar | This is worth exploring (with mem-usage and speed tests) "Pablo Aguilar" <paguilarg@hotmail.com> wrote in message news:d2akni$hbu$1@digitaldaemon.com... > Here's what I think is an interesting use case for string_view: > > <code> > > class named_class > { > string name const(); > // ... other properties > }; > > typedef std::map<string_view,named_class> container; > > </code> > > Replacing what could've been: > - map<string,named_class> duplicating name values > - vector<named_class> having to mantain element order manually > - vector<named_class> with linear searching > > using the string_view, you can take advantage of map's functionality, without paying for duplicated name strings > > Just a thought... > > > Pablo |
Copyright © 1999-2021 by the D Language Foundation