c++.stlsoft - A use case for string_view
- Pablo Aguilar <paguilarg hotmail.com> Mar 28 2005
- "Matthew" <admin.hat stlsoft.dot.org> Apr 05 2005
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
Mar 28 2005
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
Apr 05 2005








"Matthew" <admin.hat stlsoft.dot.org>