blob: cabe45fab6108e9f640adffb09e52763358ceb0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <string>
#include <iostream>
template <auto from, auto to>
auto substr(const std::string& input) -> std::string {
return input.substr(from, to-from);
}
struct X {
std::string input;
X(const std::string& input) : input{input} { }
template <auto from, auto to>
auto substr() -> std::string {
return input.substr(from, to-from);
}
};
main: () -> int = {
test_string: std::string = "The rain in Spain flows mainly down the drain";
std::cout << substr<4,8>(test_string) << "\n";
x: X = test_string;
std::cout << x.substr<4,8>() << "\n";
}
|