Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <cstddef>
  2.  
  3. struct wrapped_float
  4. {
  5. std::size_t value; //Initialize with sizeof(wrapped_float)
  6. float other; //Actual info
  7. };
  8.  
  9. constexpr wrapped_float const a{ sizeof(a), 0 }; //OK
  10.  
  11. struct test1 {
  12. static constexpr wrapped_float const b{ sizeof(b), 0 }; //Error!
  13. };
  14.  
  15. struct test2 {
  16. static constexpr wrapped_float const b{ sizeof(test::b), 0 };
  17. };
  18.  
  19. struct test3 {
  20. static constexpr wrapped_float const b{ sizeof(decltype(b)), 0 };
  21. };
  22.  
  23. int main() {
  24. return a.value + test1::b.value + test2::b.value + test3::b.value;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement