std::map, pointer to map key value, is this possible?

Section 23.1.2#8 (associative container requirements): The insert members shall not affect the validity of iterators and references to the container, and the erase members shall invalidate only iterators and references to the erased elements. So yes storing pointers to data members of a map element is guaranteed to be valid, unless you remove that element.

Python, MySQL and SELECT output to dictionary with column names for keys

For me, this worked: cursor = conn.cursor(dictionary=True) Detailed example: import mysql.connector # pip install mysql-connector-python conn = mysql.connector.connect(host=”localhost”, user=”user”, passwd=”pass”, database=”dbname”) cursor = conn.cursor(dictionary=True) sql = “SELECT * FROM `table` WHERE 1” cursor.execute(sql) rows = cursor.fetchall() for row in rows: row[“col”]

What’s the difference between set and map in C++?

They are semantically different. Consider: #include <set> #include <map> #include <utility> #include <iostream> using namespace std; int main() { pair<int, int> p1(1, 1); pair<int, int> p2(1, 2); set< pair<int, int> > s; s.insert(p1); s.insert(p2); map<int, int> m; m.insert(p1); m.insert(p2); cout << “Set size = ” << s.size() << endl; cout << “Map size = ” … Read more

Converting dynamic type to dictionary C#

You can fill the dictionary using reflection: public Dictionary<String, Object> Dyn2Dict(dynamic dynObj) { var dictionary = new Dictionary<string, object>(); foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(dynObj)) { object obj = propertyDescriptor.GetValue(dynObj); dictionary.Add(propertyDescriptor.Name, obj); } return dictionary; }

How to get around lack of covariance with IReadOnlyDictionary?

You could write your own read-only wrapper for the dictionary, e.g.: public class ReadOnlyDictionaryWrapper<TKey, TValue, TReadOnlyValue> : IReadOnlyDictionary<TKey, TReadOnlyValue> where TValue : TReadOnlyValue { private IDictionary<TKey, TValue> _dictionary; public ReadOnlyDictionaryWrapper(IDictionary<TKey, TValue> dictionary) { if (dictionary == null) throw new ArgumentNullException(“dictionary”); _dictionary = dictionary; } public bool ContainsKey(TKey key) { return _dictionary.ContainsKey(key); } public IEnumerable<TKey> Keys … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)