vendredi 22 décembre 2017

unable to aggregate initialise a variable of type structure with bit field members wrapped in class template

template<typename Type_>
struct Guarded_ : EndianGuard_ {
  Guarded_();
  Guarded_ (T_& Value) : Value (Value) {};
  ~Guarded_ () {};
  Type_ Value;
};

template<typename Type_>
Guarded_::Guarded_ () {
  uint8_t* ByteData = (uint8_t*) this;
  for (int i = 0; i < sizeof (Type_); i++) {
    ByteData[i] = 0;
  }
}

struct Slot_2 {
  uint8_t Slot :    4;
  uint8_t Unit :    3;
  uint8_t Bus :     2;
  uint8_t Unused :  7;
};

Guarded_<Slot_2> Slot = {7, 6, 1, 0};

I get no instance of constructor matches given argument list (int, int, int, int) error.

Is it a compiler bug? My bitfield struct qualifies for aggregate initialization.

Aucun commentaire:

Enregistrer un commentaire