must_be_derived Struct Template Reference
[Constraints Utility Library]

#include <stlsoft/util/constraints.hpp>

List of all members.


Detailed Description

template<typename D, typename B>
struct stlsoft::must_be_derived< D, B >

Constraint to ensure that the one type is convertible to another via inheritance, but is not the same type.

Parameters:
D The derived type
B The base type
It may be used as follows:
  class Parent {};
  class Child : public Parent {};
  class Orphan {};

  stlsoft::must_be_derived<Parent, Parent>(); // Compile error!
  stlsoft::must_be_derived<Child, Parent>();  // Ok
  stlsoft::must_be_derived<Child, Child>();   // Compile error!
  stlsoft::must_have_base<Child, Parent>();   // Compile error!

  stlsoft::must_be_derived<Orphan, Parent>(); // Compile error!
  stlsoft::must_be_derived<Orphan, Child>();  // Compile error!
  stlsoft::must_be_derived<Parent, Orphan>(); // Compile error!
  stlsoft::must_be_derived<Child, Orphan>();  // Compile error!

Note:
This extension to the must_have_base constraint was proposed by Peter Bannister after reading Chapter 1 of Imperfect C++.
See also:
stlsoft::must_have_base

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

Generated on Thu Jun 10 08:59:02 2010 for STLSoft by  doxygen 1.5.6