Will this is silly:
#define public_functions public
#define public_member public
#define public_classes public
#define private_functions private
#define private_member private
#define private_classes public
- Does not give you an more real extra information
- Break Syntax Highlighting
- Makes anybody reading the code go uhhhh
- Is not enforced by the language.
- The last one is public why why why
.
#define private_classes public // WHY WHY WHY
###Exceptions
class bad_cast
{
public_functions:
bad_cast()
: m_Msg("bad_cast: invalid conversion of a Whatever object")
{}
const char* what()
{
return m_Msg;
}
private_member:
const char* m_Msg;
};
There is already a std::bad_cast why re--invent it.
Exceptions should probably inherit from std::runtime_error if you are going to write them (that way you can use there version of what() and storage).
Talking of what() it should definitely by marked cost. And under no circumstances should it throw. So the actual declaration you want is:
const char* what() const throws (); // or noexcept on modern compiler
###class Whatever
The copy constructor
Whatever& operator = (const Whatever& what)
Does not provide the strong exception guarantee. Learn to use the copy and swap idiom it will save you.
Stop using Yoda Conditionals
if (nullptr != m_WrappedValue)
This technique is like 20 years old. It was not popular then it is way out dated now. It adds a cognitive burden to the reader that is not necessary. It provides no actual benefits. What you are trying to achieve (detection of accidental assignment) can be done by the compiler already.
###This is useless trick
The same affect can be achieved by just declaring a class.
lambda((std::vector<int>::iterator out)
{
std::cout << *out;
return *out;
}, 1);
// The equivalent without the overhead of any new operations.
class exp1 {
std::vector<int>::iterator operator()(std::vector<int>::iterator out) const {
std::cout << *out;
return *out;
}
};
Also this does not have the disadvantage of a macro. Which is a really confusing message if you add a comma anywhere in the code block.