mercredi 25 mai 2016

Temporary of non-literal type in a constant expression

struct Foo {
  bool m_b;
  Foo(bool b) {m_b = b}  
}; 

 boost::mpl::vector<Foo(true)> bar;

Would give me error: temporary of non-literal type 'Foo' in a constant expression.

My workaround is

tempalate <bool b>
struct Foo {
  bool m_b = b;
}; 

 boost::mpl::vector<Foo<true>> bar;

But I am wondering if a) that's the textbook way and b) if my first example can be make to work.

Aucun commentaire:

Enregistrer un commentaire