File: heterogeneous.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (14 lines) | stat: -rw-r--r-- 807 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
The associative containers offered by bf(C++) allow us to find a value (or
values) matching a given key. Traditionally, the type of the key used for the
lookup must match the container's key type. 

Since the C++14 standard arbitrary lookup key types can be used provided a
comparison operator is available to compare that type with the container's key
type.  Thus, a tt(char const *) key (or any other type for which an
tt(operator<) overload for tt(std::string) is available) can be used to lookup
values in a tt(map<std::string, ValueType>). This is called 
    emi(heterogeneous lookup).

Heterogeneous lookup is allowed when the comparator given to the associative
container does allow this. The standard library classes tt(std::less) and
tt(std::greater) were augmented to allow heterogeneous lookup.