This is neat and C++11 is pretty exciting, but one thing that C++ doesn't need is the further propagation of tuples into non-generic code. Requiring make_tuple instead of allowing shorthand was the right decision.<p>Tuples in python are a reasonable tradeoff between not wanting to declare anything and the hassle of anonymous structure. This doesn't apply C++ where the equivalent is the POD struct:<p><pre><code> //In the olden days we could not initialize a map inline like this
//Key -> metadata mapping. Unfortunately strutcts cannot be declared
//inside a template declaration.
struct TagData { int start; int length; StrToStr mapfun; };
const map<const string, const TagData> TagDataMap {
{"title" , { 3, 30, stripnulls}},
{"artist" , { 33, 30, stripnulls}},
{"album" , { 63, 30, stripnulls}},
{"year" , { 93, 4, stripnulls}},
{"comment" , { 97, 29, stripnulls}},
{"genre" , {127, 1, ord}}};
</code></pre>
Creating a named struct pays off when it's time to use the Map, no extra locals or tie() needed to write clear code:<p><pre><code> //for loops over collections are finally convenient to use.
for(auto td : TagDataMap){
//C++ created a horrible precedent by making the data type of
//a map pair<K,V> instead of struct ValueType { K key; V value; };
auto tdd = td.second;
ret[td.first] = tdd.mapfun(sbuf.substr(tdd.start, tdd.length));
}
</code></pre>
<a href="http://liveworkspace.org/code/bcd52515fb7161858e974b7ff3c0aac5" rel="nofollow">http://liveworkspace.org/code/bcd52515fb7161858e974b7ff3c0aa...</a>