// ----------------------------------------------------------------------
//
// conditnl.cc - Check operands 2/3 in a conditional expression
//
// History:
//   15-Jun-2000  WEB  Initial draft, adapted from (whimsical) Dickens.cc
//   25-Apr-2001  WEB  s/<ISOcxxSyntax.hh>/"ISOcxx\/ISOcxxSyntax.hh"/
//
// ----------------------------------------------------------------------


#include "ISOcxx/ISOcxxSyntax.hh"


// A tale of two types (with apologies to Charles Dickens):
struct Royalty;
struct Commoner;


// Commoners live a lonely life and are stuck with their lot:
struct Commoner  { };


// Royalty, however, can choose to mingle with the rabble:
struct Royalty  {
  #ifndef DEFECT_CONDITIONAL  /* compliant */
    operator  Commoner const &  () const  { static Commoner x; return x; }
  #else                       /* defective */
    operator  Commoner          () const  { static Commoner x; return x; }
  #endif
};


// Commoners are indistinguishable:
bool operator== ( Commoner, Commoner )  { return true; }


// The plot commenceth:
int  main()  {

  // Our protagonists:
  Royalty   prince;
  Commoner  pauper;

  // Some other ragamuffin:
  Commoner  beggar = ( prince == pauper )
                   ? prince
                   : pauper;

  // Go home:
  return ! ( beggar == pauper );

}  // The End
