Frederick said:
Steven T. Hatton:
If you don't mind, I'll make that more readable:
struct Bar {
void f()
{
struct Local {
Local()
{
std::cout << "I am local" << std::endl;
}
};
Local l;
}
};
If you turn off word wrap you will see what I consider readable in
comparison to the accepted formatting styles.
namespace std {
template<typename T>struct equal_to : binary_function<T, T, bool>{
bool operator()(const T& x, const T& y) const; };
template<typename T>struct not_equal_to : binary_function<T, T, bool>{
bool operator()(const T& x, const T& y) const; };
template<typename T>struct greater : binary_function<T, T, bool>{
bool operator()(const T& x, const T& y) const; };
template<typename T>struct less : binary_function<T, T, bool>{
bool operator()(const T& x, const T& y) const; };
template<typename T>struct greater_equal: binary_function<T, T, bool>{
bool operator()(const T& x, const T& y) const; };
}
sprawling code over multiple lines often accomplishes little more than
hiding symmetries and obscuring higher level structure in a program.
What's so great about this? I don't understand what you're trying to do.
If you want to embed one function inside another, then simple do:
void Func()
{
struct InnerStruct {
static void OtherFunc()
{
/* Some code */
}
};
InnerStruct::OtherFunc();
}
The point was that I didn't think it was possible to define a local class in
C++. IIRC, I tried when I first started with C++ and was not able to make
it work. There are probably numerous modestly useful variants possible for
using local classes.