On Monday, 15 August 2016 at 14:40:14 UTC, Chris Wright wrote:
You still haven't defined the term "design by introspection". Some searching around says it's the pattern of:

template Foo(T) {
  static if (is(typeof(T.bar)) {
    // preferred implementation takes advantage of T.bar
  } else {
    // alternate (also correct) implementation
  }
}

For instance, if T is an allocator and it has a `realloc` method, the preferred implementation, which uses `realloc`, will be chosen. Otherwise, the alternate implementation (which might use a linked list to avoid reallocating) will be chosen.

Strategy pattern at compile time.

Reply via email to