PPL  0.12.1
Parma_Polyhedra_Library::Is_Same_Or_Derived< Base, Derived > Struct Template Reference

A class holding a constant called value that evaluates to true if and only if Base is the same type as Derived or Derived is a class derived from Base. More...

#include <meta_programming.hh>

Inheritance diagram for Parma_Polyhedra_Library::Is_Same_Or_Derived< Base, Derived >:

List of all members.

Classes

struct  Any
 A class that is constructible from just anything. More...

Public Types

enum  const_bool_value { value = (sizeof(func(derived_object())) == sizeof(char)) }

Public Member Functions

 PPL_COMPILE_TIME_CHECK (sizeof(char)!=sizeof(double),"architecture with sizeof(char) == sizeof(double)"" (!?)")

Static Public Member Functions

static char func (const Base &)
 Overloading with Base.
static double func (Any)
 Overloading with Any.
static const Derived & derived_object ()
 A function obtaining a const reference to a Derived object.

Detailed Description

template<typename Base, typename Derived>
struct Parma_Polyhedra_Library::Is_Same_Or_Derived< Base, Derived >

A class holding a constant called value that evaluates to true if and only if Base is the same type as Derived or Derived is a class derived from Base.

Note:
Care must be taken to use this predicate with template classes. Suppose we have
  template <typename T> struct B;
  template <typename T> struct D : public B<T>;
Of course, we cannot test if, for some type variable U, we have Is_Same_Or_Derived<B<U>, Type>:: const_bool_value:: value == true. But we can do as follows:
  struct B_Base {
  };

  template <typename T> struct B : public B_Base;
This enables us to inquire Is_Same_Or_Derived<B_Base, Type>:: const_bool_value:: value.

Definition at line 223 of file meta_programming.hh.


Member Enumeration Documentation

template<typename Base, typename Derived>
enum Parma_Polyhedra_Library::Is_Same_Or_Derived::const_bool_value
Enumerator:
value 

Assuming sizeof(char) != sizeof(double), the C++ overload resolution mechanism guarantees that value evaluates to true if and only if Base is the same type as Derived or Derived is a class derived from Base.

Definition at line 247 of file meta_programming.hh.

                        {
    value = (sizeof(func(derived_object())) == sizeof(char))
  };

Member Function Documentation

template<typename Base, typename Derived>
static const Derived& Parma_Polyhedra_Library::Is_Same_Or_Derived< Base, Derived >::derived_object ( )
static

A function obtaining a const reference to a Derived object.

template<typename Base, typename Derived>
static char Parma_Polyhedra_Library::Is_Same_Or_Derived< Base, Derived >::func ( const Base &  )
static

Overloading with Base.

template<typename Base, typename Derived>
static double Parma_Polyhedra_Library::Is_Same_Or_Derived< Base, Derived >::func ( Any  )
static

Overloading with Any.

template<typename Base, typename Derived>
Parma_Polyhedra_Library::Is_Same_Or_Derived< Base, Derived >::PPL_COMPILE_TIME_CHECK ( sizeof(char)!  = sizeof(double))

The documentation for this struct was generated from the following file: