consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View 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

View File

@@ -0,0 +1,19 @@
#include <iostream>
#include "C.h"
int main() {
int i1 = 1;
int i2 = 2;
C<int> o1;
C<double> o2;
C<const char*> o3;
C<int*> o4;
std::cout << o1.less(i1, i2) << " ";
std::cout << o2.less(1.2, 3.4) << " ";
std::cout << o3.less("abcd", "abcx") << " ";
std::cout << o4.less(&i1, &i2) << std::endl;
//o2=o1;
return 0;
}