[ create a new paste ] login | about

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

C++, pasted on Oct 31:
#include <iostream>

    #pragma pack(push, 1)
    template <typename T>
    struct S
    {
       T t;
    
       inline void Set(const T& val) { std::cout << "general\n"; }
    };

    template <int len>
    struct S<char[len]>
    {
       char t[len];
    
       inline void Set(const std::string& val) { std::cout << "specialization\n"; }
    };
    #pragma pack(pop)

int main() {

    S<int> a;
    a.Set(10);

    S<char[20]> b;
    b.Set("turkey!");

    return 0;
}


Output:
1
2
general
specialization


Create a new paste based on this one


Comments: