Debian Codegraph @

yo/advancedtemplates/concepts/examples/stridx.cc

raw
1 #include <string>
2 #include <map>
3
4 //stridx
5 template <typename Type>
6 concept HasStrIndex =
7 requires(Type tp)
8 {
9 tp[std::string{}];
10 };
11
12 template <HasStrIndex Type>
13 auto value(Type &obj, std::string const &key)
14 {
15 return obj[key];
16 }
17
18 int main()
19 {
20 std::map<std::string, double> msd;
21 value(msd, "hi");
22 }
23 //=