- 1
if(!(a - b))
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+8
if(!(a - b))
+10
string intArrayToString(int* array, int size)
{
ostringstream ss;
ss << "[";
for (int i=0; i<size-1; i++)
ss << array[i] << ",";
ss << array[size-1];
ss << "]";
return ss.str();
}
string longIntArrayToString(long int* array, int size)
{
ostringstream ss;
ss << "[";
for (int i=0; i<size-1; i++)
ss << array[i] << ",";
ss << array[size-1];
ss << "]";
return ss.str();
}
О шаблонах мы, видимо, не в курсе. Ну и упаси вас боже передать суда size=0.
Думаю, сюда можно смело выкладывать весь источник, но уж больно он уныл
https://github.com/adobe-research/libkafkaАдобъ Рисёрчъ на острие прогресса#ifdef DEBUG
#define D(x) x
#else
#define D(x)
#endif
#define E(x) cout.flush() << xТак ведь и придётся своего клиента писать... :(
+5
template <class ResultBinaryFunc, class BinaryFunc1, class BinaryFunc2>
class complex_binary_compose: public std::binary_function<BinaryFunc1::first_argument_type,
BinaryFunc1::second_argument_type,
ResultBinaryFunc::result_type>
{
public:
complex_binary_compose(const ResultBinaryFunc & BF, const BinaryFunc1 & UF1, const BinaryFunc2 & UF2) :
_bf(BF), _f1(UF1), _f2(UF2) {}
result_type operator()(first_argument_type arg1, second_argument_type arg2)
{
return _bf(_f1(arg1, arg2), _f2(arg1, arg2));
}
private:
ResultBinaryFunc _bf;
BinaryFunc1 _f1;
BinaryFunc2 _f2;
};
template <class ResultBinaryFunc, class BinaryFunc1, class BinaryFunc2>
complex_binary_compose<ResultBinaryFunc, BinaryFunc1, BinaryFunc2>
complex_compose2(const ResultBinaryFunc & BF, const BinaryFunc1 & UF1, const BinaryFunc2 & UF2)
{
return complex_binary_compose<ResultBinaryFunc, BinaryFunc1, BinaryFunc2>(BF, UF1, UF2);
}
Чтобы было удобно применять stl алгоритмы.
+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