Friday, April 15, 2011

Cómo especializar un template para arrays

#include <iostream>

template < typename T >
struct Example
{
    static inline void call()
    {
        std::cout << "non-array" << std::endl;
    }
};

template < typename T, unsigned int N >
struct Example< T[N] >
{
    static inline void call()
    {
        std::cout << "array" << std::endl;
    }
};

int main()
{
    Example < int[5][10] >::call();
    Example < float[10] >::call();
    Example < float >::call();
}

Resultado:

array
array
non-array

1 comment:

  1. Win big with a deposit bonus - JTM Hub
    The first real money online 포항 출장마사지 casino to earn a 광주광역 출장샵 deposit is NetEnt. The company recently launched a unique betting 시흥 출장마사지 option called Playwin. 나주 출장샵 These 제주도 출장마사지 online slots

    ReplyDelete