template syntax
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Jan 30 22:59:02 UTC 2019
On Wed, Jan 30, 2019 at 01:54:47PM -0800, Walter Bright via Digitalmars-d wrote:
> On 1/30/2019 12:12 PM, H. S. Teoh wrote:
> > Please, let's leave C++'s < > mistake in the dustbins of history.
> > Such suffering ought not be inflicted upon our future generations.
>
> To pile it on, C++ iostreams overloads << and >> operators.
Sigh, you made me do it. Couldn't resist:
#include <iostream>
struct Sigh { };
struct You {
Sigh operator>>(std::string s) { return Sigh(); }
} U;
struct Me { };
struct Do {
Me operator<(Sigh m) { return Me(); }
} traits;
struct It { } T;
struct Couldnt {
void operator,(Me i) {
std::cout << "Goodbye, earth" << std::endl;
}
};
struct Resist {
void operator()(std::string msg) {
std::cout << msg << std::endl;
}
Couldnt operator<(It t) { return Couldnt(); }
} fun;
int main() {
// What does this line do?
fun<T, traits<U>>("Hello world");
}
:-D
T
--
Never trust an operating system you don't have source for! -- Martin Schulze
More information about the Digitalmars-d
mailing list