[ create a new paste ] login | about

Link: http://codepad.org/3DXoBLTf    [ raw code | output | fork ]

C++, pasted on Oct 31:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

#pragma pack(push, 1)
template <typename T>
struct S
{
   T t;

   inline void Set(const T& val) {std::cout << sizeof(val) << '\n';}
};
#pragma pack(pop)

int main() {
    typedef char (carray)[10];
    S<carray> lhs;
    carray rhs = "HELLO";
    lhs.Set(rhs);
    std::cout << sizeof(lhs) << '\n';
    std::cout << sizeof(rhs) << '\n';
    return 0;
}


Output:
1
2
3
10
10
10


Create a new paste based on this one


Comments: