summaryrefslogtreecommitdiff
path: root/libcutl/cutl/meta/polymorphic-p.hxx
blob: dd820db87dd08f3992b44918ccb67124fee65ac7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// file      : cutl/meta/polymorphic-p.hxx
// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license   : MIT; see accompanying LICENSE file

#ifndef CUTL_META_POLYMORPHIC_HXX
#define CUTL_META_POLYMORPHIC_HXX

#include <cutl/meta/class-p.hxx>
#include <cutl/meta/remove-cv.hxx>

namespace cutl
{
  namespace meta
  {
    template <typename CVX>
    struct polymorphic_p
    {
      typedef typename remove_cv<CVX>::r X;

      template <typename Y, bool C>
      struct impl
      {
        static const bool r = false;
      };

      template <typename Y>
      struct impl<Y, true>
      {
        struct t1: Y
        {
          t1 ();
        };

        struct t2: Y
        {
          t2 ();

          virtual
          ~t2 () throw ();
        };

        static const bool r = sizeof (t1) == sizeof (t2);
      };

      static const bool r = impl<X, class_p<X>::r>::r;
    };
  }
}

#endif // CUTL_META_POLYMORPHIC_HXX