fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. using namespace std;
  5.  
  6. template <typename T>
  7. typename std::enable_if<sizeof(T)<16, size_t>::type Align(T*)
  8. {
  9. return 10;
  10. }
  11.  
  12. template <typename T>
  13. typename std::enable_if<sizeof(T)>=16, size_t>::type Align(T*)
  14. {
  15. return 20;
  16. }
  17.  
  18. //strategy for "int" type
  19. size_t Align(int*)
  20. {
  21. return 18;
  22. }
  23.  
  24. int main() {
  25. // your code goes here
  26. int i;
  27. char j;
  28. char f[1000];
  29.  
  30. std::cout << Align(&i) << std::endl;
  31. std::cout << Align(&j) << std::endl;
  32. std::cout << Align(&f) << std::endl;
  33. return 0;
  34. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
18
10
20