Home » Community » Newbie corner » Ini file
Re: Ini file [message #58106 is a reply to message #58105] |
Wed, 16 February 2022 10:24   |
jjacksonRIAB
Messages: 227 Registered: June 2011
|
Experienced Member |
|
|
In a dictionary, map and other associative containers, both elements together (key and value) are commonly called key-value pairs, or a pair for short.
>that does not work
I'm assuming you looked up KeyValueRef and tried to roll your own?
template <class K, class V>
struct KeyValueRef {
const K& key;
V& value;
KeyValueRef(const K& key, V& value) : key(key), value(value) {}
};
The reason your version doesn't work is because references *must* be initialized at time of creation, they cannot be nullptr and they cannot be changed to point to something else. That's one of the major differences between a reference and a pointer - so if you look at the code above you'll see that in the constructor those references are being initialized at key(key), value(value). That's why that version works and yours doesn't.
[Updated on: Wed, 16 February 2022 10:47] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu May 01 01:16:13 CEST 2025
Total time taken to generate the page: 0.05012 seconds
|