aboutsummaryrefslogtreecommitdiff
path: root/odb/details/meta/polymorphic-p.hxx
blob: 6e9514491842011b37bb344cc25cf7deede93126 (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
52
53
54
// file      : odb/details/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_DETAILS_META_POLYMORPHIC_HXX
#define ODB_DETAILS_META_POLYMORPHIC_HXX

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

namespace odb
{
  namespace details
  {
    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_DETAILS_META_POLYMORPHIC_HXX