Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Ini file
Re: Ini file [message #58106 is a reply to message #58105] Wed, 16 February 2022 10:24 Go to previous messageGo to previous message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 221
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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Synchronize to Github
Next Topic: ref questions
Goto Forum:
  


Current Time: Sat May 11 13:07:40 CEST 2024

Total time taken to generate the page: 0.03785 seconds