cf5-opt is configured for windows.

_.cpp is updated for more options.
Also a test is done on implicite copy constructor generation for a derived
class.
This commit is contained in:
2013-06-22 22:55:32 +04:00
parent 543a2948a7
commit 58b05cd1f4
4 changed files with 145 additions and 22 deletions

View File

@@ -0,0 +1,84 @@
/* Check cf5-opt.vim defs.
VIM: let g:lcppflags="-std=c++11 -O2 -pthread"
VIM-: let g:cppflags=g:Iboost.g:Itbb
VIM-: let g:ldflags=g:Lboost.g:Ltbb.g:tbbmalloc.g:tbbmproxy
VIM-: let g:ldlibpath=g:boostld.g:tbbld
VIM-: let g:cf5output=0
*/
/*
* Conclusion:
* Per C++ standard since Son doesn't have explicitely defined copy
* assignement operator the an implicite one is generated which call
* Base::operatro = () as a result overriden operator in the Son is not
* called.
*/
#include <iostream>
#include <exception>
class Base
{
public:
int b;
virtual Base &operator=(const Base & o)
{ std::cout << "Base" << std::endl; b=o.b; return *this; };
};
class Derived : public Base
{
public:
int d;
virtual Base &operator=(const Base &)
{ std::cout << "Derived 1" << std::endl; return *this;};
virtual Derived &operator=(const Derived &)
{ std::cout << "Derived 2" << std::endl; return *this;};
};
class Son : public Base
{
public:
int d;
virtual Base &operator=(const Base &)
{ std::cout << "Son" << std::endl; return *this;};
};
int main ( void )
{try{
Derived d1, d2;
d1.b = 0;
d2.b = 1;
d1.d = 0;
d2.d = 1;
Base * b1 = &d1;
Base * b2 = &d2;
*b1 = *b2;
std::cout << d1.b << d1.d << std::endl;
d1 = d2;
Son s1, s2;
s1 = s2;
return 0;
}
catch ( const std::exception& e )
{
std::cerr << std::endl
<< "std::exception(\"" << e.what() << "\")." << std::endl;
return 2;
}
catch ( ... )
{
std::cerr << std::endl
<< "unknown exception." << std::endl;
return 1;
}}