boost::apply_if

loki でちょっとひねりゃできるじゃん。今頃気付いてすみません。

namespace Loki {
  template <bool flag, class T, class U>
  struct Select {
    typedef T Type;
  };

  template <class T, class U>
  struct Select<false, T, U> {
    typedef U Type;
  };

  /* Select 使いまわしで boost::apply_if できるよ〜 */
  template <bool flag, class T, class U>
  class ApplyIf {
    typedef typename Select<flag, T, U>::Type TheSelected;
  public:
    typedef typename TheSelected::Type Type;
  };
} // namespace Loki