For example, initially I have an example program:
#include<iostream>
Now I want to change std::cin (to provide more functions, for example, calling a function when input fails). Therefore, I present the title of mystd.h as:
#include<iostream>
But the change seems uncomfortable. (Users must specify all components using std::sort;using mystd::cin; or replace all cin with mystd::cin . mystd::cin using namespace std;using mystd::cin; causes cin ambiguous)
In fact, I'm going to write a modified standard library and use it as conveniently as the original one. The ideal code I want for users to be able to write is:
(PS: this means that mystd can simply be used as std , and does not mean that I want users to use using namespace everywhere)
#include<iostream>
I tried adding using namespace std; in mystd , but also causes ambiguity.
One of the difficult decisions I can make is to create a using statement, such as using std::string; in mystd , for all std members that have not been changed.
Is there a more practical way to implement mystd.h ?
c ++ c ++ 11
James
source share