fork download
  1. #include <iostream>
  2.  
  3. template <class T, class U>
  4. int f(T t, U)
  5. {
  6. U a(t);
  7. return a;
  8. }
  9.  
  10. struct S {
  11. unsigned char a:3;
  12. unsigned char b:2;
  13. };
  14.  
  15. int main()
  16. {
  17. S s;
  18. s.a = 7;
  19. std::cout << int(s.a) << '\t' << f(s.a, s.b) << std::endl;
  20. }
  21.  
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
7	7