aboutsummaryrefslogtreecommitdiff
path: root/odb/meta/polymorphic-p.hxx
blob: 571ef52310d019249bb2d8e27282831ade8b7447 (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
51
// file      : odb/meta/polymorphic-p.hxx
// author    : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
// license   : GNU GPL v2; see accompanying LICENSE file

#ifndef ODB_META_POLYMORPHIC_HXX
#define ODB_META_POLYMORPHIC_HXX

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

namespace odb
{
  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 // ODB_META_POLYMORPHIC_HXX