Some tests are reduced to single cpp.

This commit is contained in:
2014-05-31 23:22:19 +04:00
parent 09c9e7caaf
commit 8fa0b18c4b
22 changed files with 19 additions and 1388 deletions

123
cpp/multiple_derivation.cpp Normal file
View File

@@ -0,0 +1,123 @@
#include <stdio.h>
#include <windows.h>
class a
{
public:
virtual void f() = 0;
};
class b : public virtual a
{
public:
virtual void g() = 0;
};
class c : public virtual a
{
int n;
public:
c()
{ n = 0; }
virtual void f()
{ ++n; }
};
class d : public b, public c
{
public:
// virtual void f()
// {
// c::f();
// }
virtual void g()
{
puts( "d::g()" );
}
};
class a2
{
public:
virtual void f() = 0;
};
class b2 : public virtual a
{
public:
virtual void g() = 0;
};
class c2 : public a2
{
int n;
public:
c2()
{ n = 0; }
virtual void f()
{ ++n; }
};
class d2 : public b2, public c2
{
public:
virtual void f()
{
c2::f();
}
virtual void g()
{
puts( "d::g()" );
}
};
int main(int argc, const char * argv[])
{
const int nAmount = 1000000000;
d o;
d2 o2;
int nWins1 = 0;
int nWins2 = 0;
//for ( ; true ; )
{
DWORD dwStart = GetTickCount();
for ( register int n = nAmount; n; --n )
o.f();
DWORD dwDuration = GetTickCount() - dwStart;
printf( "Virtual inheritence takes %dms\n", dwDuration );
DWORD dwStart2 = GetTickCount();
for ( register int n = nAmount; n; --n )
o2.f();
DWORD dwDuration2 = GetTickCount() - dwStart2;
printf( "Redirection of function %dms\n", dwDuration2 );
if ( dwDuration2 > dwDuration )
++nWins1;
else
++nWins2;
printf( "count %d : %d\n\n", nWins1, nWins2 );
}
return 0;
}

32
cpp/std_locale.cpp Normal file
View File

@@ -0,0 +1,32 @@
/* Check cf5-opt.vim defs.
VIM: let g:lcppflags="-std=c++11 -O2 -pthread"
VIM: let g:wcppflags="/O2 /EHsc /DWIN32"
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:Bboost.g:Btbb
VIM: let g:argv=""
VIM-: let g:cf5output=0
*/
#include <locale>
#include <iostream>
int main(int argc, const char* argv[])
try
{
std::cout << "name of current global locale: " << std::locale().name() << "\n";
std::cout << "name of classic C locale: " << std::locale::classic().name() << "\n";
std::cout << "name of \"user's preferred locale\": " << std::locale("").name () << "\n";
std::cout.imbue( std::locale( "fr" ) );
std::cerr.imbue( std::locale( "en_US" ) );
std::cout << "fr: " << 1.1 << std::endl;
std::cerr << "us: " << 1.1 << std::endl;
return 0;
}
catch (...)
{
std::cerr << "crash!!!" << std::endl;
return 1;
}