@@ -45,7 +45,6 @@ namespace bio::ranges
45
45
* \ingroup container
46
46
* \tparam key_t The key type; must be convertible to std::string_view (e.g. also std::string).
47
47
* \tparam mapped_t The mapped type; must be an object type.
48
- * \tparam mapped_t_is_context_aware See below.
49
48
*
50
49
* This container behaves like a mixture of std::vector and std::unordered_map.
51
50
*
@@ -76,18 +75,13 @@ namespace bio::ranges
76
75
*
77
76
* \include test/snippet/ranges/container/dictionary.cpp
78
77
*
79
- * ### Context-aware mapped value types
78
+ * ### Static string element access
80
79
*
81
- * If the template parameter `mapped_t_is_context_aware` is set to true, the #reference type of the dictionary
82
- * becomes `bio::meta::tuple<key_t const &, mapped_t const &>`, i.e. the mapped value in dictionary elements cannot be
83
- * changed via regular element access.
84
- *
85
- * Additionally, given an object `o` of type `mapped_t`, if `get<"foo">(o)` is valid,
80
+ * Given an object `o` of type `mapped_t`, if `get<"foo">(o)` is valid,
86
81
* this container provides a special interface:
87
82
*
88
83
* * A `get<"foo">(dict)` friend function that calls `get<"foo">(dict.at("foo"))`.
89
84
* * The `.at("foo"_vtag)` and `operator["foo"_vtag]` member functions with identical semantics.
90
- * * These functions may or may not expose mutable references to the mapped value (or one of its members).
91
85
*
92
86
* In combination with element types that are derived from std::variant (and additionally provide the aforementioned
93
87
* string-based get-interface), this can be used to create heterogeneous dictionaries, i.e. transparent access
@@ -96,7 +90,7 @@ namespace bio::ranges
96
90
* \include test/snippet/ranges/container/dictionary_het.cpp
97
91
*
98
92
*/
99
- template <typename key_t , typename mapped_t , bool mapped_t_is_context_aware = false >
93
+ template <typename key_t , typename mapped_t >
100
94
class dictionary
101
95
{
102
96
public:
@@ -108,17 +102,13 @@ class dictionary
108
102
/* !\name Associated types
109
103
* \{
110
104
*/
111
- using mapped_ref_t =
112
- std::conditional_t <mapped_t_is_context_aware, mapped_t const &, mapped_t &>; // !< Usually `mapped_t &`.
113
- using value_type = meta::tuple<key_t , mapped_t >; // !< The value_type type.
114
- using reference = meta::tuple<key_t const &, mapped_ref_t >; // !< The reference type.
115
- using const_reference = meta::tuple<key_t const &, mapped_t const &>; // !< The const_reference type.
116
- using difference_type = ptrdiff_t ; // !< The difference_type type.
117
- using size_type = size_t ; // !< The size_type type.
118
- using const_iterator = detail::random_access_iterator<dictionary const >; // !< The const_iterator type.
119
- using iterator = std::conditional_t <mapped_t_is_context_aware,
120
- const_iterator,
121
- detail::random_access_iterator<dictionary>>; // !< The iterator type.
105
+ using value_type = meta::tuple<key_t , mapped_t >; // !< The value_type type.
106
+ using reference = meta::tuple<key_t const &, mapped_t &>; // !< The reference type.
107
+ using const_reference = meta::tuple<key_t const &, mapped_t const &>; // !< The const_reference type.
108
+ using difference_type = ptrdiff_t ; // !< The difference_type type.
109
+ using size_type = size_t ; // !< The size_type type.
110
+ using iterator = detail::random_access_iterator<dictionary>; // !< The iterator type.
111
+ using const_iterator = detail::random_access_iterator<dictionary const >; // !< The const_iterator type.
122
112
// !\}
123
113
124
114
// !\cond
@@ -536,7 +526,7 @@ class dictionary
536
526
*
537
527
* Basic exception guarantee.
538
528
*/
539
- mapped_ref_t at (het_key_t key)
529
+ mapped_t & at (het_key_t key)
540
530
{
541
531
auto it = key_to_index.find (key);
542
532
if (it == key_to_index.end ())
@@ -570,7 +560,7 @@ class dictionary
570
560
*
571
561
* Basic exception guarantee.
572
562
*/
573
- mapped_ref_t operator [](het_key_t key) { return at (key); }
563
+ mapped_t & operator [](het_key_t key) { return at (key); }
574
564
575
565
// !\copydoc operator[](het_key_t key)
576
566
mapped_t const & operator [](het_key_t key) const { return at (key); }
@@ -601,7 +591,7 @@ class dictionary
601
591
*/
602
592
template <small_string key>
603
593
friend decltype (auto ) get(meta::decays_to<dictionary> auto && dict)
604
- requires(mapped_t_is_context_aware && requires { get<key>(get<1 >(dict.storage [0 ])); })
594
+ requires(requires { get<key>(get<1 >(dict.storage [0 ])); })
605
595
{
606
596
#ifdef __cpp_lib_generic_unordered_lookup
607
597
auto it = dict.key_to_index .find (key);
0 commit comments