Thing2:
1. struct Thing2 {
2. std::string _payload;
3. int _n{0};
4.
5. Thing2(std::string_view text) : _payload(text) {}
6. Thing2(std::string_view text, int x) : _payload(text), _n(x) {}
7.
8. Thing2 * _next_name {nullptr};
9. Thing2 * _prev_name {nullptr};
10.
11. struct LinkByName {
12. static Thing2*&
13. next_ptr(Thing2 *thing)
14. {
15. return thing->_next_name;
16. }
17. static Thing2 *&
18. prev_ptr(Thing2 *thing)
19. {
20. return thing->_prev_name;
21. }
22. static std::string_view
23. key_of(Thing2 *thing)
24. {
25. return thing->_payload;
26. }
27. static constexpr std::hash<std::string_view> hasher{};
28. static auto
29. hash_of(std::string_view s) -> decltype(hasher(s))
30. {
31. return hasher(s);
32. }
33. static bool
34. equal(std::string_view const &lhs, std::string_view const &rhs)
35. {
36. return lhs == rhs;
37. }
38. };
39.
40. Thing2 *_next_n{nullptr};
41. Thing2 *_prev_n{nullptr};
42.
43. struct LinkByN {
44. static Thing2*&
45. next_ptr(Thing2 *thing)
46. {
47. return thing->_next_n;
48. }
49. static Thing2 *&
50. prev_ptr(Thing2 *thing)
51. {
52. return thing->_prev_n;
53. }
54. static int
55. key_of(Thing2 *thing)
56. {
57. return thing->_n;
58. }
59. static int
60. hash_of(int n)
61. {
62. return n;
63. }
64. static bool
65. equal(int lhs, int rhs)
66. {
67. return lhs == rhs;
68. }
69. };
70. };