-
+21
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
if(m_bitRate < DSS_LOW_RATE/1000000.)
{
m_bitRate = DSS_LOW_RATE/1000000.;
}
else if(m_bitRate > DSS_HIGH_RATE/1000000.)
{
m_bitRate = DSS_HIGH_RATE/1000000.;
}
else if(m_bitRate > (.5*(DSS_HIGH_RATE - DSS_LOW_RATE) + DSS_LOW_RATE)/1000000.)
{
m_bitRate = DSS_HIGH_RATE/1000000.;
}
else
{
m_bitRate = DSS_LOW_RATE/1000000.;
}
умиляет. ну хотя бы, упростить .5*(DSS_HIGH_RATE - DSS_LOW_RATE) + DSS_LOW_RATE) до (DSS_HIGH_RATE + DSS_LOW_RATE)/2 -- понятнее, да? тогда и if(m_bitRate > DSS_HIGH_RATE/1000000.) можно убрать за ненадобносью (ибо число которое больше чем максимальное из двух точно больше чем среднее из этих жвух), и самое верхнее if(m_bitRate < DSS_LOW_RATE/1000000.) можно убрать ибо в else у нас то же самое произойдет - и сразу как бы читаестя с ходу и понимается, не надо напрягаться.
Боже, как я люблю крупные проприетарные проекты написанные людьми выбравшими для себя не свою профессию разработчика софта...
Pencioner,
11 Октября 2012
-
+32
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
#include <iostream>
void f(char c) { std::cout << "f(char)" << std::endl; }
void f(signed char c) { std::cout << "f(signed char)" << std::endl; }
void f(unsigned char c) { std::cout << "f(unsigned char)" << std::endl; }
int main()
{
f('a');
f((signed char)('a'));
f((unsigned char)('a'));
return 0;
}
илитный ресурс сегодня мне раскрыл глаза на очередное крестоблядство керниган-гай-ричи-блядство:
с:
The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char.
Irrespective of the choice made, char is a separate type from the other two and is not compatible with either.
с++:
Characters can be explicitly declared unsigned or signed. Plain char, signed char, and unsigned char are three distinct types.
defecate-plusplus,
08 Октября 2012
-
+38
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
#include <iostream>
using namespace std;
class Program
{
public:
friend int main()
{
return 0;
}
};
Мой знакомый говорит, что его компилятор поддерживает Java\C#-нотацию точки входа таким образом. И ещё он говорит, что так должно компилироваться по стандарту.
LispGovno,
07 Октября 2012
-
+33
- 1
- 2
- 3
- 4
- 5
- 6
- 7
class Chatter : public QListBoxItem {
[...]
private:
static ChatterRef *chatters[MAX_NUM_CHATTERS];
[...]
friend int main(int, char *argv[]); // to destroy chatters[]
};
Сам проект: http://www.qtchat.org/qtchat/
Пример дается в этой книге: http://books.google.ru/books?id=8lYbNfsAVT4C&dq=qtchat&source=g bs_navlinks_s как пример friend-функций
myaut,
07 Октября 2012
-
+36
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
gp_terrains.at(0)->draw();
//it took me only 50 lines of spaghetti code to implement the spiral layout
//direction 1 for +x, 2 for +y, 3: -x, 0: -y
int repetition_count = 1;
int i = 1;
int direction = 0;
while(i < (int)gp_terrains.size()) {
for (int k = 0; k < 2; k++) {
direction = (++direction) % 4;
for (int j = 0; j < repetition_count; j++) {
switch(direction) {
case 1: {
glTranslated(512, 0, 0);
gp_terrains.at(i)->draw();
break;
}
case 2: {
glTranslated(0, 512, 0);
gp_terrains.at(i)->draw();
break;
}
case 3: {
glTranslated(-512, 0, 0);
gp_terrains.at(i)->draw();
break;
}
case 0: {
glTranslated(0, -512, 0);
gp_terrains.at(i)->draw();
break;
}
}
if (++i >= (int)gp_terrains.size())
break;
}
if (i >= (int)gp_terrains.size())
break;
}
if (i >= (int)gp_terrains.size())
break;
repetition_count++;
catcall,
07 Октября 2012
-
+20
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
D:\Sources\jimbot_at_cpp>make -f Makefile.win clean-full
rm -f *.o lib.a dist/jimbot.exe
D:\Sources\jimbot_at_cpp>make -f Makefile.win lib
gcc -c sqlite3.c -pipe -O2 -g1 DSQLITE_THREADSAFE=1
gcc.exe: error: DSQLITE_THREADSAFE=1: No such file or directory
make: *** [lib] Error 1
D:\Sources\jimbot_at_cpp>make -f Makefile.win
g++ -c *.cpp -std=c++0x -O2 -g1 -pipe -Wno-deprecated -Wno-write-strings -Wno-de
precated-declarations -DDEBUG -DEASTER -DTESTER
g++ -o dist/jimbot -pipe *.o -O2 -g1 lib.a -lpthread -lgnutls -lwsock32 -ladvap
i32 -lcrypt32 -lsecur32 -ldnsapi -liconv
g++.exe: error: lib.a: No such file or directory
make: *** [all] Error 1
D:\Sources\jimbot_at_cpp>
JavaCoder,
06 Октября 2012
-
+29
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
template <class Monad>
struct XMapM {
template <class F, class M> struct Sig : FunType<F,M,
typename RT<typename ::fcpp::BindM<Monad>::Type,M,typename LEType<
LAM<LV<1>,CALL<typename ::fcpp::UnitM<Monad>::Type,
CALL<F,LV<1> > > > >::Type>::ResultType> {};
template <class F, class M>
typename Sig<F,M>::ResultType
operator()( const F& f, const M& m ) const {
LambdaVar<1> A;
return bindM<Monad>()( m, lambda(A)[ unitM<Monad>()[f[A]] ] );
}
};
Хаскель не нужен.
serpinski,
05 Октября 2012
-
+28
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
std::string toString(std::function<std::string(T)> f = std::function<std::string(T)>()) {
std::stringstream ss;
if(f)
ss << f(some_value);
else
ss << some_value;
return ss.str();
}
an0nym,
03 Октября 2012
-
+42
- 1
- 2
- 3
- 4
objbase.h:
#define __STRUCT__ struct
#define interface __STRUCT__
спасибо Микрософт за счастливое детство соответствие стандарту при засирании глобального неймспейса своими больными фантазиями
defecate-plusplus,
03 Октября 2012
-
+36
- 1
printf("Aligment control: %d", sizeof(DataTransfer_T));
LispGovno,
02 Октября 2012