brintos

brintos / llvm-project-archived public Read only

0
0
Text · 786 B · 407ba68 Raw
16 lines · cpp
1template <class T> int staticSizeof() {2  return sizeof(T);3}4 5template <class T1, class T2, class... Ts> int staticSizeof() {6  return staticSizeof<T2, Ts...>() + sizeof(T1);7}8 9int main (int argc, char const *argv[])10{11  int sz = staticSizeof<long, int, char>();12  return staticSizeof<long, int, char>() != sz; //% self.expect("expression -- sz == staticSizeof<long, int, char>()", "staticSizeof<long, int, char> worked", substrs = ["true"])13                                  //% self.expect("expression -- sz == staticSizeof<long, int>() + sizeof(char)", "staticSizeof<long, int> worked", substrs = ["true"])14                                  //% self.expect("expression -- sz == staticSizeof<long>() + sizeof(int) + sizeof(char)", "staticSizeof<long> worked", substrs = ["true"])15}16