MTSL/h/specialization.h

62 lines
855 B
C++

//
// Created by dongl on 22-9-29.
//
#include <cstddef>
#ifndef MSTL_SPECIALIZATION_H
#define MSTL_SPECIALIZATION_H
#endif //MSTL_SPECIALIZATION_H
/// 模板特化 specialization
template<class type>
struct hash{
};
template<>
struct hash<char>{
size_t operator() (char x) const {
return x;
}
};
template<>
struct hash<int>{
size_t operator() (int x) const {
return x;
}
};
template<>
struct hash<long>{
size_t operator() (long x) const {
return x;
}
};
/// partial specialization 模板偏特化 局部特化 个数上的偏
template<typename T, typename Alloc>
class m_vector{
};
template<typename Alloc>
class m_vector<bool, Alloc>{
};
/// partial specialization 模板偏特化 局部特化 范围上的偏
template<typename T>
class C{
};
template<typename T>
class C<T*>{
};