consolidate all repos to one for archive
This commit is contained in:
32
semester_2/programiranje_2/primeri/Example20/C.h
Normal file
32
semester_2/programiranje_2/primeri/Example20/C.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef EXAMPLE20_C_H
|
||||
#define EXAMPLE20_C_H
|
||||
|
||||
#include <cstring>
|
||||
|
||||
// primary template
|
||||
template < typename T >
|
||||
class C {
|
||||
public:
|
||||
bool less (const T& v1, const T& v2) {
|
||||
return v1<v2;
|
||||
}
|
||||
};
|
||||
|
||||
// explicit template specialization
|
||||
template<>
|
||||
class C<const char*> {
|
||||
public:
|
||||
bool less (const char* v1, const char* v2) {
|
||||
return strcmp(v1,v2)<0;
|
||||
}
|
||||
};
|
||||
|
||||
// partial specialization
|
||||
template< typename T >
|
||||
class C<T*> {
|
||||
public:
|
||||
bool less (T* v1, T* v2) {
|
||||
return *v1 < *v2; }
|
||||
};
|
||||
|
||||
#endif //EXAMPLE20_C_H
|
||||
Reference in New Issue
Block a user