On Wednesday, 16 January 2013 at 18:38:21 UTC, Mehrdad wrote:
On Wednesday, 16 January 2013 at 11:00:48 UTC, mist wrote:
When you have a ton of similar lines of code which need to be edited in parallel, lining them up lets you edit all of them in one keystroke. Saves me quite a lot of annoying editing in the long run, actually.

When you have a ton of similar lines of code, you'd better start thinking about templates or mixins :P


Easy to say in theory, but makes absolutely no sense in many cases. =P

Example:
boost::unordered_set<int> foo;
boost::unordered_map<int> bar;


and now I want to change 'boost' to 'std' because C++11 came out.

Templates? Mixins? wtf lol

Another example:

template<class T> struct foo
{
        int x;
        int operator+(int) const { }
        int operator-(int) const { }
        int operator*(int) const { }
};

template<class T> int foo<T>::operator+(int x) const { return this->x + x; } template<class T> int foo<T>::operator-(int x) const { return this->x - x; } template<class T> int foo<T>::operator*(int x) const { return this->x * x; }



let's say now I want to add a new template parameter, class U, to all the functions.



If you can teach me how "templates" or "mixins" would solve my problem here I'd love to know.

Reply via email to