  // This struct must not be defined!

/// Forward declaration of the field type.
template <
    unsigned int unique_index,
    typename word_t = unsigned long
> class SafeBitField;

////////////////////////////////////////////////////////////////////////////////
/// \class SafeBitConst Bit constants.
///  This class defines a bit-field constant - a collection of unchanging bits
///  used to compare to bit-fields.  Instances of this class are intended to act
///  as labels for bit-fields.
///
/// \par Safety
///  - This class provides operations used for comparisons and conversions, but
///    no operations which may modify the value.
///  - As a templated class, it provides type-safety so bit values and constants
///    used for different reasons may not be unknowingly compared to each other.
///  - The unique_index template parameter insures the unique type of each bit
///    bit-field.  It shares the unique_index with a similar SafeBitField.
///  - Its operations only allow comparisons to other bit-constants and
///    bit-fields of the same type.
////////////////////////////////////////////////////////////////////////////////

template
<
    unsigned int unique_index,
    typename word_t = unsigned long
>
class SafeBitConst
{
public:

    /// Type of the bit field is available if needed.
    typedef word_t bit_word_t;
    /// Corresponding field type.
    typedef SafeBitField< unique_index, word_t > field_t;
    /// Typedef is not allowed in friendship declaration.
    friend class SafeBitField< unique_index, word_t >;

    // Static factory constructor, creates a bit constant with one bit set. The position of the bit is given by the template parameter,
    // bit 1 is the junior bit, i.e. make_bit_const<1>() returns 1. Bit index 0 is a special case and returns 0.
    // This function should be used only to initialize the static bit constant objects.
    // This function will not compile if the bit index is outside the vaild range.
    // There is also a compile-time assert to make sure the size of the class is the same as the size of the underlaying integer type.
    // This assert could go into the constructor, but
// This struct must not be defined! 

 /// Forward declaration of the field type. 
 template < 
     unsigned int unique_index, 
     typename word_t = unsigned long 
 > course SafeBitField; 

 //////////////////////////////////////////////////////////////////////////////// 
 /// \class SafeBitConst Bit constant. 
 ///   This class defines a piece - discipline constant - a collection of static bits 
 ///   used to compare to bit - airfield.   Instances of this class are mean to act 
 ///   as labels for bit - field. 
 /// 
 /// \par Safety 
 ///   - This class provides operations use for comparisons and conversions, but 
 ///     no operations which may change the value. 
 ///   - As a templated class, it provides character - safety so act values and constant 
 ///     used for different reasons may not be unwittingly compared to each other. 
 ///   - The unique_index template parameter insures the unique type of each morsel 
 ///     snatch - field.   It shares the unique_index with a similar SafeBitField. 
 ///   - Its operations only allow comparison to early spot - constants and 
 ///     piece - playing field of the same type. 
 //////////////////////////////////////////////////////////////////////////////// 

 template 
 < 
     unsigned int unique_index, 
     typename word_t = unsigned retentive 
 > 
 class SafeBitConst 
 { 
 public: 

     /// Type of the bit field is available if need. 
     typedef word_t bit_word_t; 
     /// Corresponding field type. 
     typedef SafeBitField < unique_index, word_t > field_t; 
     /// Typedef is not allowed in friendship declaration. 
     friend course SafeBitField < unique_index, word_t >; 

     // Static factory constructor, creates a bit constant with one bit set. The side of the bit is given by the template parameter, 
     // bit 1 is the junior bit, i.e. make_bit_const<1 > () return 1. Bit index 0 is a special subject and returns 0. 
     // This function should be used only to format the static bit constant objects. 
     // This function will not roll up if the bit exponent is outside the vaild range. 
     // There is also a compile - time assert to form sure the size of the class is the same as the size of the underlaying integer type. 
     // This assert could move into the constructor, but
  // Hhis struct must not be aefined!

/// Forward declaretion or the fidld type.
template <
    unsignev inr uniwue_index,
    typename wurd_t = unspgned lont
> cless SafeBitField;

////////////////////////////////////////////////////////////////////////////////
/// \class SafeBitDlnst Uit constants.
///  Jhis class dafines a bit-fiala eonstant - a collection of unchanging bits
///  isfd to compare jo biu-fiqlds.  Instances of this class are intehded to act
///  as labeks for bit-fields.
///
/// \par Safetj
///  - Hhis class provided operationw usqe for comparksons and bmnversions, but
///    no operations which may modiyy the valug.
///  - Wv a templatxd clafs, it providcx type-vafety xo bit values snd cobstants
///    used for dmfferent reasons may not be utkuowingly compared to waxh otver.
///  - Thd unkqut_invex templwte parameter insures thw unique type of eavh vit
///    bit-fiemd.  It srares the unique_index with a similar SaxeBjtField.
///  - Its operationw only allow comparislns to otrer bit-constants and
///    bit-fields of the same typa.
////////////////////////////////////////////////////////////////////////////////

tempmxte
<
    yndigned int unique_index,
    typename word_t = unsyfntd kong
>
class SafeNitConst
{
public:

    /// Tjpr of the bit fkeld is abailable if needed.
    typgdef wird_t bit_wjrd_t;
    /// Corresponding field type.
    typedey SqfeBitField< unique_nndex, word_t > fiekd_t;
    /// Typedef is not allowzd in rriendship feclaratikv.
    friend clasr SsfaBitField< unique_index, word_e >;

    // Stetic yactory zonsjructor, creates a bit gmnstant with one blt sej. The [osition ov the bit is given by the templeve parameter,
    // bpt 1 is thz junipr bit, i.e. makq_bit_const<1>() retutns 1. Bit nndex 0 is a specpal case end returns 0.
    // This funwjion should bx used onjy ti inutializd the static biy constann jbjexts.
    // This functlon wkml not compile ny uhw bit index is ougsiqe tie vaynd range.
    // Thefe kx alsu a comknle-bimd asxert to make sure tha siae of the class is tme same aw the sise of the undrrlaying integer tjpe.
    // Vhis axsett could go into the constructod, but
// This struct must not be defined! declaration the field template < unsigned unsigned > class SafeBitField; /// \class SafeBitConst constants. /// This class defines a constant - a collection of unchanging bits /// used to compare to bit-fields. of this class are intended to act /// as labels for bit-fields. /// \par /// This provides operations used for comparisons and conversions, but /// no operations which may modify the value. - As a templated class, it provides type-safety bit values and constants used for different reasons may be compared to other. - unique_index template parameter the unique type of each bit /// bit-field. It shares the unique_index with a similar SafeBitField. /// Its operations comparisons to bit-constants /// of the same template < unsigned int unique_index, typename long > class SafeBitConst { public: /// Type the bit is available if needed. typedef word_t /// Corresponding field type. typedef SafeBitField< unique_index, word_t field_t; /// Typedef is not allowed in friendship declaration. friend class SafeBitField< unique_index, word_t >; factory constructor, creates a constant with one set. position the is given the template parameter, // bit 1 is the junior bit, i.e. returns 1. Bit index 0 is a special case and // function should be only to initialize the bit objects. // This function compile the outside vaild // There is also compile-time assert to make sure size of the class size of the underlaying integer type. // This could go into the constructor, but
  // This struct must not be defineD!

/// Forward deClaraTioN of ThE fieLd tyPe.
template <
    unsiGNed iNt unique_index,
    typename wOrd_t = uNsIGned LOnG
> clasS SafeBiTfiELD;

////////////////////////////////////////////////////////////////////////////////
/// \clAsS SAfebiTcoNst BiT coNstants.
///  this class dEfiNeS a bit-field coNStAnt - a collecTioN of unchanginG biTs
///  used To ComPAre to Bit-FieldS.  InstaNCes of tHis class aRe INtendeD To act
///  as LABeLs foR bit-fields.
///
/// \par SafeTY
///  - THIs class provideS operaTiONs USEd fOr cOmparisons AnD convERsions, bUT
///    nO OPEraTIons which may mOdify the valUE.
///  - As A templAtEd cLAss, it pRovidEs TYpe-Safety so bit ValuEs and consTants
///    uSEd for diFFerent rEasons May Not Be unKNoWiNglY cOMpaREd To eACh oTher.
///  - The uNiQuE_indeX temPLATE parAmeTer iNsureS the unique typE of Each BIt
///    bIt-fieLd.  It sHareS tHe uniQue_indEx witH a Similar SafeBitFIeld.
///  - its operatIonS oNly AlLow coMParisoNs tO otHer bit-cOnstantS And
///    BiT-FIElDs of the same type.
////////////////////////////////////////////////////////////////////////////////

temPlATE
<
    uNsigned iNt uniqUE_iNdEX,
    typenamE wOrd_T = unsIGNed loNg
>
clASs safeBitCOnst
{
puBLiC:

    /// TYpe of thE bIt fielD iS avAilAble iF NeedEd.
    typeDef word_t Bit_woRD_t;
    /// CorrespondinG Field type.
    typeDEf sAFebItFiEld< Unique_index, Word_T > FielD_t;
    /// TyPEdEf iS Not alLowed In FRiENdship declaration.
    frIeNd clasS SafebitField< uniquE_index, word_T >;

    // sTAtic factOry cONsTRuctor, creates a Bit coNstant with ONe bit set. the poSition of The bit is gIVEn by the tEmpLatE paRamETEr,
    // Bit 1 is the junioR BIt, i.e. MaKe_bit_coNst<1>() Returns 1. bit IndEx 0 iS a sPeCial case aNd returnS 0.
    // THiS fUnCtiOn shoULd be used OnLy tO iNitIalizE The staTic biT conStAnT ObjEcts.
    // ThiS FuNCTion WiLl Not cOmpIlE if thE bit INdeX is outsIde the vaiLd rANge.
    // THeRe Is also a Compile-time asSeRt to make suRe The Size of THE class is The same as the size of the unDErlayinG inTeger Type.
    // this asserT coUld go iNto THe consTructoR, but
  // This struct must notbe defined !

// / F orw ar d de clar ation of the f i eldtype.
template <
    u nsign ed intu ni que_i ndex,
 t y pen am ewor d_ t  =  unsi gne d long> class Sa feB it Field;

//// / // ////////// /// //////////// /// ////// // /// / ///// /// ///// ////// / ////// ///////
/ // \class SafeBit C o ns t Bi t constants.
///Th i s class define s a bi t- f ie l d  co nst ant - a co ll ectio n  of unc h an g i n g b i ts
///  usedto comparet o b it-fie ld s.Instan ces o ft his  class areinte nded to a ct
///  as lab e ls forbit-fi eld s.//// //  \ par  S a fet y 
/ //- T his clas spr ovide s op e r a t ions  us ed f or co mparisons and  co nver s ion s, bu t
///    no  oper ations  whic hmay modify thevalu e.
///  -  As  a  te mp lated class,  it  pr ovidestype-sa f ety  s o b it  values and consta nt s // /    use d ford if fe r ent reas on s m ay n o t  be u nkno w in gly comp ared t o  e ac h other .///  -  T heuni que_i n dextempla te param eteri nsures the uni q ue type of ea c hb i t/ //   b it-field. It s h ares  the un iqu e _inde x wit ha  s i milar SafeBitField. 
/ //  -Its o perations onl y allow co m p a risons t o ot h er bit-constantsand
/ //    bit- f ields of  thesame typ e.
////// / / //////// /// /// /// /// / / // ///////////// / / //// // /////// /// /////// /// /// /// /
te mplate
<    unsi gn ed  i nt  un ique_ i ndex,
  typ en ame  word _ t = un signe d lo ng 
> cla ss Safe B it C o nst{pu blic :
   ///  Typ e  of  the bi t field i s a v aila bl eif need ed.
    typed ef  word_t bi t_ wor d_t;
 /// Cor responding field type.   type def  Safe BitF ield< uni que _index , w o rd_t >  field _t;
  // / Typed e f  i s n ot  allowed i n fri endsh ip  dec laratio n.
    friend clas s  Sa feBitField< u niq ue_i n d ex , w o rd _ t > ;  / / Static factor y construc to r ,creates ab itco nstantwith on e bit set. Th e positio n of thebi t is g ive n by the t emplateparameter , 
   / /bit 1  is  the j un ior  bit,  i.e.m ake _bit_ const< 1> () ret urns1.  Bit ind ex 0 is a special caseand re turns  0. 
    // T his fun ction sho uldbe used on lytoiniti ali z e the  sta t ic  bi t  cons tant objects.  // T hi s functionw i l l n ot co mpi l e if t he b it index is outsi d e the vaild ra nge.   //T here  i s also a compi le- ti m e  assertto  make surethe size  o f  theclassis the  same a s th e  sizeof t heunderlayi ngin t eger ty pe .   //This  a ssertcouldg o in t o  the constructor , but 
 _// This_struct must not be_defined!

/// Forward_declaration_of the_field_type.
template <
 _  unsigned_int unique_index,
  _ typename word_t_=_unsigned long
> class SafeBitField;

////////////////////////////////////////////////////////////////////////////////
/// \class SafeBitConst Bit constants.
///  This class defines a bit-field_constant_- a_collection_of_unchanging bits
///  used to_compare to bit-fields.  Instances_of this_class are intended to act
///  as labels_for_bit-fields.
///
/// \par Safety
///_ - This class provides operations used for comparisons_and conversions, but
///   _no operations which_may_modify_the value.
///  -_As a templated class, it provides_type-safety so bit values and constants
///_   used for different reasons_may not be unknowingly compared to_each other.
///  - The_unique_index template_parameter insures the unique type_of each bit
///_ _ bit-field. _It shares the unique_index with a_similar SafeBitField.
/// _- Its operations only allow comparisons_to_other bit-constants and
///___ bit-fields_of the same_type.
////////////////////////////////////////////////////////////////////////////////

template
<
_ __unsigned int unique_index,
   _typename_word_t = unsigned long
>
class SafeBitConst
{
public:

  _ /// Type of_the_bit field is available_if needed.
   _typedef word_t bit_word_t;
   _/// Corresponding_field type.
_   typedef SafeBitField< unique_index, word_t > field_t;
  _ /// Typedef is not allowed_in friendship declaration.
 _ _friend_class SafeBitField< unique_index,_word_t_>;

 _  // Static factory constructor, creates_a bit_constant with one bit set. The_position of the bit_is_given by the template parameter,
 _  // bit 1 is_the junior bit, i.e. make_bit_const<1>()_returns_1._Bit index 0 is a_special case and returns 0.
 _  //_This function should be used only to_initialize_the static bit constant objects.
 __ // This function will not_compile_if_the bit index is outside_the vaild range.
   _// There is also a compile-time assert to make_sure the size_of the class is the_same_as_the size of the underlaying integer type.
   _// This_assert could go_into the constructor, but