fork download
  1. #include <stdexcept>
  2. using namespace std;
  3.  
  4. struct Foo
  5. {
  6. unsigned small_value;
  7. };
  8.  
  9. class SmallValue
  10. {
  11. unsigned value;
  12. public:
  13. SmallValue(unsigned x=0)
  14. {
  15. if(x>100) throw invalid_argument("");
  16. value = x;
  17. }
  18. };
  19. struct Bar
  20. {
  21. SmallValue small_value;
  22. };
  23.  
  24. template<typename T>
  25. void same_syntax()
  26. {
  27. T x;
  28. x.small_value = 11;
  29. }
  30.  
  31. int main()
  32. {
  33. same_syntax<Foo>();
  34. same_syntax<Bar>();
  35. }
Success #stdin #stdout 0s 2848KB
stdin
Standard input is empty
stdout
Standard output is empty