The examples for D while they will most likley compile, it's not really how one would write D templates today. I also provide usage examples showing that everything compiles as expected.
Set example:
// no need to use the template keyword
struct Set(T) if(is(typeof(T.init == T.init))) // Verify T has equlity
{
void add(T o) {}