Any disadvantage of using const reference when iterating over basic types?

The standard containers all return references from their iterator (note, however, that some “containers aren’t really container, e.g., std::vector<bool> which returns a proxy). Other iterators might return proxies or values although this isn’t strictly supported. Of course, the standard doesn’t make any guarantees with respect to performance. Any sort of performance related feature (beyond complexity … Read more

How to pass a template function in a template argument list

I suspect the answer is “you cannot do this”. Yes, that is the case, you cannot pass a function template as a template argument. From 14.3.3: A template-argument for a template template-parameter shall be the name of a class template or an alias template, expressed as id-expression. The template function needs to be instantiated before … Read more

Tools to generate higher-quality error messages for template-based code?

Let’s have a stab at an answer (I marked this community wiki so we get a good response together)… I’m working since a long time with templates and error messages have generally improved in some way or another: Writing a stack of errors creates a lot more text but also typically includes the level the … Read more

Do we still need to write the empty angle brackets when using transparent std function objects?

GCC is wrong. There is already a bug report. [dcl.type.simple]/2 says: A type-specifier of the form typenameopt nested-name-specifieropt template-name is a placeholder for a deduced class type ([dcl.type.class.deduct]). And [dcl.type.class.deduct]/2 says: A placeholder for a deduced class type can also be used in the type-specifier-seq in the new-type-id or type-id of a new-expression, as the … Read more

(Re)named std::pair members

I don’t see how you can possibly do better than struct city { string name; int zipcode; }; There’s nothing non-essential there. You need the types of the two members, your whole question is predicated around giving names to the two members, and you want it to be a unique type. You do know about … Read more

Choosing the right UI templating tool – dust.js? [closed]

Dust.js is a good option. It is better than some of the other templating frameworks because it does not constrain that the data should be in a file, or in a string, etc. Also it is being actively maintained https://github.com/linkedin/dustjs. Has it been successful? Yes, I know at least LinkedIn is using it and also … Read more

How to print the value of a key containing dots

As @martin-ghallager said, one needs to use an external function to access those elements. Helpfully, the standard library already provides the index function (which does exactly what Martin’s dotNotation function does). To use it just write: {{ index .Data “core.value” }} The index function will return a default value in case the key is not … Read more

used without template parameters

VisitedSet is a template, not a class, so you can’t use VisitedSet in a nested name specifier such as VisitedSet::getSize(). Just as you specified the declaration of class VisitedSet<T> for all class T, you must specify the definition of VisitedSet<T>::getSize() for all class T: template<class T> int VisitedSet<T>::getSize() { // ^^^ return vec.size(); } The … Read more

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