Talk:More C++ Idioms/Algebraic Hierarchy

The intent is not clear and the very-very long sample code is an overkill for a textbook, that too at an intermediate reader level.

Regards, --Jyoti.mickey (talk) 06:33, 9 October 2009 (UTC)

SmartPointer
Isn't that just a smart pointer?

Does not compile
Does not compile with g++ using --std=c++14. Some of the classes do not have any public member function or constructors.

Moreover, sometimes rep is sometimes assigned to be a zero pointer and dereferences rep in swap.

Name
Reading the description I think it doesn't match with the name of the idiom.

The sample code looks different from the original paper where algebraic hierarchy pattern is introduced.

http://tinf2.vub.ac.be/~dvermeir/c++/EuroPLoP98.html#AlgebraicHierarchy

std::swap
Don't specialize swap in namespace std - swap(T, T) should be declared in the same namespace as T, so that it will be found by ADL when necessary.

See http://en.cppreference.com/w/cpp/algorithm/swap and https://stackoverflow.com/questions/14402990/should-you-overload-swap-in-the-std-namespace

Second declaration of Number n2 = n3; // Re-labelling.
Is it a error ?:

Number n2 = n3; // Re-labelling.  ММЛ (discuss • contribs) 19:31, 11 April 2024 (UTC)