- 1
- 2
- 3
- 4
- 5
# ifndef BOOST_NO_PARTIAL_SPECIALIZATION
, check<Model>
# else
, check<failed ************ Model::************>
# endif
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+8
# ifndef BOOST_NO_PARTIAL_SPECIALIZATION
, check<Model>
# else
, check<failed ************ Model::************>
# endif
+58
Poor man' link time code generation:
#include "main.cpp"
#include "frame.cpp"
#include "func.cpp"
#include "account.cpp"
#include "advancer.cpp"
#include "audit.cpp"
#include "cpio.cpp"
g++ -whole-program -o my books.exe -O3 includeall.cpp
http://blogs.msdn.com/b/oldnewthing/archive/2014/06/06/10531604.aspx
+7
typedef SmartPtr<CallRec> callptr;
callptr *m_call;
if (m_call && (*m_call) && (*m_call)->SomeMethod()) {
// ...
}
GnuGK и смартпоинтеры.
+13
#define _BEGIN_LOCK(_Kind) \
{ \
typedef int _TmpTestType; \
__if_exists(_TmpTestType::ToString) \
{ \
bool _MustReleaseLock = false; \
int _LockKind = _Kind; \
System::Runtime::CompilerServices::RuntimeHelpers::PrepareConstrainedRegions(); \
try \
} \
{ \
__if_exists(_TmpTestType::ToString) \
{ \
System::Runtime::CompilerServices::RuntimeHelpers::PrepareConstrainedRegions(); \
try { } _M_CEE_FINALLY \
{ \
_STD _Lockit::_Lockit_ctor(_LockKind); \
_MustReleaseLock = true; \
} \
} \
__if_not_exists(_TmpTestType::ToString) \
{ \
_STD _Lockit _Lock(_Kind); \
}
+17
~Guard(){
if(std::uncaught_exception())
try{
}catch(...){
error_output<<"prevented exception!!!"<<endl;
};
}
+8
#define FOR_INCLUSION (iostream) (studio.h) (stdlib.h) (boost/phoenix.hpp) (my_drugs_library.h)
#include <include_and_disable_some_warnings>
+5
#include <iostream>
using namespace std;
struct ko{
int r;
} f;
const ko& taras=f;
int main() {
cout<<
is_same<decltype(taras.r), int>::value
<<" "<<
is_same<decltype((taras.r)), const int &>::value
<<endl;
return 0;
}
What is output you expect? You should answer without looking at ideone link and without using compiler.
http://ideone.com/5O9vtZ
+6
const int cx = 5;
int main() {
auto lam = [cx]() mutable {cx=40;};
return 0;
}
Will it compile or not? Why?
http://ideone.com/gtlXKb
+3
#define BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(TRAITS_PREFIX, TYPEDEF_TO_FIND) \
template <class T>\
struct TRAITS_PREFIX##_bool\
{\
template<bool Add>\
struct two_or_three {one _[2 + Add];};\
template <class U> static one test(...);\
template <class U> static two_or_three<U::TYPEDEF_TO_FIND> test (int);\
static const std::size_t value = sizeof(test<T>(0));\
};\
\
template <class T>\
struct TRAITS_PREFIX##_bool_is_true\
{\
static const bool value = TRAITS_PREFIX##_bool<T>::value > sizeof(one)*2;\
};\
//
Ну тут как бы все просто и понятно. Но зачем заканчивают макрос кодом
\
//
?
+5
struct A {
int a;
virtual ~A() {}
};
struct B: public A {
int b;
B(int _b):b(_b){}
virtual ~B() {}
};
A func(){return A();}
int main(int argc, char* argv[])
{
A* a = new B(2);
*a = func();
a->a = 5;
B *b = dynamic_cast<B*>(a);
std::cout << b->b << "\t" << b->a;
return 0;
}
Меня попросили ответить что выведет на экран.