title: Compile time behaviour branch based on derived type
body: <p>I have a pair of classes FS and DS which both derived from another class S. I have a function into which I pass in an S* (ie an FS or DS), which further calls another function passing in the same S*. In this final function I need to have different behaviour based on whether the S is an FS or DS, but would prefer to resolve this branch at compile time due to it being on a critical path. How can I achieve this? Something involving metaprogramming and or constexpr I feel - I don't want to be making a virtual call for each pass</p>
  
  <p>Extraneous details omitted for brevity</p>
  
  <pre><code>class S {};
  class FS : public S {};
  class DS : public S {};
  
  void func_2(Space *s) {
       // common code
       // branch based on lowest type of s
       // common code
  }
  
  void func_1(Space *s) {
      // common code
      func_2(s);
  }
  </code></pre>