C++????????Ч????????????
???????????? ???????[ 2013/5/10 9:58:21 ] ????????
??????????????д????????д????????????????ж??????????????????????????
template<bool A??typename B??typename C>
struct _if{};
template<typename B??typename C>
struct _if<true??B??C>{ typedef B Type; };
template<typename B??typename C>
struct _if<false??B??C>{ typedef C Type; };
template<typename T??size_t N>
inline size_t ARRAYSIZE(T (&)[N])
{
return N;
}
template<typename T>
struct IsInnerType { static const bool Value = false; };
template<>
struct IsInnerType<bool> { static const bool Value = true; };
template<>
struct IsInnerType<char> { static const bool Value = true; };
template<>
struct IsInnerType<short> { static const bool Value = true; };
template<>
struct IsInnerType<int> { static const bool Value = true; };
template<>
struct IsInnerType<long long> { static const bool Value = true; };
template<>
struct IsInnerType<unsigned char> { static const bool Value = true; };
template<>
struct IsInnerType<unsigned short> { static const bool Value = true; };
template<>
struct IsInnerType<unsigned int> { static const bool Value = true; };
template<>
struct IsInnerType<unsigned long long> { static const bool Value = true; };
template<typename T??size_t N>
struct ArrayAssignInnerType
{
static inline void Invoke(T (&A)[N]?? T (&B)[N])
{
memcpy(A??B??sizeof(A));
}
};
template<typename T??size_t N>
struct ArrayAssignCustomType
{
static inline void Invoke(T (&A)[N]?? T (&B)[N])
{
for(size_t i = 0; i < N; ++i)
A[i] = B[i];
}
};
template<typename T??size_t N>
inline void ArrayAssign(T (&A)[N]?? T (&B)[N])
{
_if<IsInnerType<T>::Value??ArrayAssignInnerType<T??N>??ArrayAssignCustomType<T??N> >::Type::Invoke(A??B);
}
??????????????????????????????Ч??????????д??????????????????????????????дOK???
ArrayAssign(B??A);
?????????????VC??GCC?±????????
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11