A
Alf P. Steinbach
It's Easter, so I'm flinging an egg in the direction of this newsgroup. 
<code language="C++">
// In other languages a simple task!
// The question is, could this be obfuscated even more, plus perhaps made even
// less efficient, by suitable (under-documented) standard library requirements?
#include <iostream>
#include <limits>
#include <locale>
namespace std
{
// This overload of the endl function template can't formally be in 'std',
// that is, extensions such as this are not supported.
template< typename CharT, typename Traits >
basic_istream<CharT, Traits>& endl( basic_istream<CharT, Traits>& is )
{
is.ignore(
numeric_limits<streamsize>::max(), // Incorrectly documented C++98.
Traits::to_int_type( use_facet< ctype<CharT> >( is.getloc()
).widen( '\n' ) )
);
return is;
}
}
int main()
{
using namespace std;
cout << "Press return, please: ";
cin >> endl;
}
</code>
Cheers,
- Alf
<code language="C++">
// In other languages a simple task!
// The question is, could this be obfuscated even more, plus perhaps made even
// less efficient, by suitable (under-documented) standard library requirements?
#include <iostream>
#include <limits>
#include <locale>
namespace std
{
// This overload of the endl function template can't formally be in 'std',
// that is, extensions such as this are not supported.
template< typename CharT, typename Traits >
basic_istream<CharT, Traits>& endl( basic_istream<CharT, Traits>& is )
{
is.ignore(
numeric_limits<streamsize>::max(), // Incorrectly documented C++98.
Traits::to_int_type( use_facet< ctype<CharT> >( is.getloc()
).widen( '\n' ) )
);
return is;
}
}
int main()
{
using namespace std;
cout << "Press return, please: ";
cin >> endl;
}
</code>
Cheers,
- Alf