fork download
  1. #include <memory>
  2. struct Foo
  3. {
  4. int m_field1;
  5. Foo(int field1):m_field1(field1){};
  6. };
  7.  
  8. struct BitField {
  9. struct {
  10. unsigned long Field1:31;
  11. unsigned long Field2:1;
  12. } DUMMY;
  13. };
  14. int main()
  15. {
  16. BitField *p = new BitField();
  17. //This Line compiles
  18. auto sp1 = std::shared_ptr<Foo>(new Foo((unsigned long)p->DUMMY.Field1));
  19. //But std::make_shared fails to compile
  20. auto sp2 = std::make_shared<Foo>((unsigned long)p->DUMMY.Field1);
  21. return 0;
  22. }
Success #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty