| 1 |
#include <iostream> |
| 2 |
#include <string> |
| 3 |
#include "typetype.h" |
| 4 |
|
| 5 |
template <typename Return, typename Argument> |
| 6 |
Return chop(Argument const &arg, TypeType<Argument> ) |
| 7 |
{ |
| 8 |
return Return{ arg }; |
| 9 |
} |
| 10 |
|
| 11 |
template <typename Argument> |
| 12 |
std::string chop(Argument const &arg, TypeType<std::string> ) |
| 13 |
{ |
| 14 |
return std::string{ arg, 1 }; |
| 15 |
} |
| 16 |
|
| 17 |
template <typename Result, typename Arg> |
| 18 |
Result chop(Arg txt) |
| 19 |
{ |
| 20 |
return chop(std::string{ txt }, TypeType<Result>{} ); |
| 21 |
} |
| 22 |
|
| 23 |
using namespace std; |
| 24 |
|
| 25 |
int main() |
| 26 |
{ |
| 27 |
cout << chop<string>("hello world") << '\n'; |
| 28 |
} |