Alloverloading by result -
struct var
{
private:
float a;
float b;
public:
var(float _a, float _b) : a(_a), b(_b) {}
operator int() { std::cout << "get int !"; return (int(a) & (int)b); }
operator float() { std::cout << "get float !"; return int(a * b); }
};
int main_()
{
float x = var(1, 2);
int y = var(1, 2);
}
GC -
simple reference counted smart_pointers are enough in most cases. But it's possible to write overcomplicated smart pointer, which can resolve "circular dependency" problem and there are industrial GCs for C++ (Boehm GC, f.e.)
lambda - if '__typeof__' keyword will be introduced, then we can just use boost::lamda/phoenix - like libraries, which deduce all types.
auto - IT'S GREAT! I'm missing it and vomited on BOOST_FOREACH-like hacks. will typeof/decltype feature be implemented? It's even more important, because 'auto' can be emulated -
#define AUTO(var_name, initializer) (__typeof__(initializer)) var_name = initializer;
but auto can't solve problem for _type_ deduction, nor declaration variables -
----------------------------------------------------------------
template <class T> __typeof__(false ?: a : b)
Max(const T &a, const T &b) { return a < b ? b : a }
----------------------------------------------------------------
template<class A_Function, class B_Function>
struct bind_sum_t
{
A_Function a_foo;
B_Function b_foo;
bind_sum_t(A_Function _a_foo, B_Function _b_foo) : a_foo(_a_foo), b_foo(_b_foo) { }
template <class X, class Y>
//__typeof__(a_foo(x) + b_foo(y))
int
operator()(X const &x, Y const &y)
{
return a_foo(x) + b_foo(y);
}
};
//mimics boost::lambda (_1 + _2)
template<class A_Function, class B_Function>
bind_sum_t<A_Function, B_Function> bind_sum(A_Function a_foo, B_Function b_foo)
{
return bind_sum_t<A_Function, B_Function>(a_foo, b_foo);
}
----------------------------------------------------------------
Will there be the __typeof__/decltype keyword ?
Properities -
You are bored on SetValue/GetValue?
Use overloaded function Value instead.
if name of method is noun - than it's not action, it's property.
class Bar
{
private:
int m_iWidth;
public:
int Width() const { return m_iWidth; }
void Width(int w) { m_iWidth = w; }
};
usage:
m_pBar->Width(10);
int w = m_pBar->Width();
There is no syntax overhead! Neither at property declaration, nor at usage.
Operator '=' is just Delphi/C# syntax sugar. And, of course, there are lots of C++ wrappers that can do this via overloaded operator= (for example,
http://www.livejournal.com/users/_winnie/17358.html ^_^ - without memory/speed overhead, without handmade tedious initialization in constructor)
C++ Demiurge How about attributes / reflection ? Managed C++ / C++/C++ prove that it can be integrated to C++. I'm bother with thousands "C++ reflection" and "C++ serialization" and "C++ advanced C++ RTTI" projects, and "CObjectBase" in each frameworks and custom fast implementation of "IsKindOf" in each framework(because dynamic_cast is slow/insufficient).
What about 3D math?
Every company/university lab has it's own math library. Sometimes two or three :) (Look at any free game engine / quake / etc
). Of course, this is math libray use SSE. And they are all not compatible. And they all compatible via (SGI_Matrix*)(float *)&IBM_Matrix44.
Why we should complicate С++ with initializes array?
I see initialization of dynamic containers only in test/'learning exercise'/sample code, not in industrial code. And even in test there it can be solved with boost::assign for perverts or good old-fashioned
int a[] = { 1, 2, 3, 4, 5, 6 };
std::vector<int> vec(a, a + ARRAY_SIZE(a));
It's not a problem at all!
Why we should complicate С++ with '>>' template parameter list ending?
There a lot more complicated problems for beginners -
what is string literal? "hello world"? What is proper copy-constructor? How should I manage resources, so they won't leak when exception is thrown? What is pointer and why array are not pointers? Where I should use char * and where - std::string? A lot, lot, lot old-C questions about memory and pointers, but without whitch nobody can write robust C++ programs.
And >> in templates is compile-time ill formed program, so it's safe. And good compiler can warn -
And, of course the main beginner question - what is difference between . and -> and why in C# and other flooffy languages there is only . ?
error: `>>' should be `> >' within a nested template argument list
or less informative -
error C2947: expecting '>' to terminate template-argument-list, found '>>'
And why do you not eliminate "no end of line at the end of file", which is UNDEFINED BEHAVIOR, and a lot of such no meaning details, if proceed the >> in templates?
Which _really_GREAT features will be in C++0X ? Which ones can allow programmer programmer to use libraries, which will extend human ability to express his intentions to computer in C++ language. Sorry, I can't follow open-std/wg21 / n####.pdf's, there are heaps of them :(
Thank you for the greatest and fastest null-overhead all-purpose language. Which is so powerful, that he can eat and mimics any other programming language.
Thank you.
PS. sorry for my funny poor Enlish, it's more difficult than C++ ^_^