- 
        
        
                −1         
                            - 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
 #include <iostream>
using namespace std;
struct NG
{
	template<class T>
	struct get
	{
		typedef typename T::f type;
	};
};
template <typename T, typename NameGetter>
struct has_member_impl
{
    typedef char matched_return_type;
    typedef long unmatched_return_type;
    
    template <typename C>
    static matched_return_type f(typename NameGetter::template get<C>*);
    
    template <typename C>
    static unmatched_return_type f(...);
    
public:
    static const bool value = (sizeof(f<T>(0)) == sizeof(matched_return_type));
};
template <typename T, typename NameGetter>
struct has_member{
   enum { value = has_member_impl<T, NameGetter>::value };
 };
 
 class T{};
int main() {
	cout<<has_member<T, NG>::value;
	return 0;
}
 
 
            http://ideone.com/4LDGhZ
         
             LispGovno,
            04 Сентября 2013 LispGovno,
            04 Сентября 2013
 
- 
        
        
                +13         
                            - 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
 TAbstractMessageFrame * SwitchIfNeedReceivePackets = create_switch(
		fnc_ext::bind(this,
					  fnc_ext::compose2(std::greater<WORD>(),
										fnc_ext::get_mem(&TThisClass::_totalDataLength),
										fnc_ext::compose1(std::bind1st(std::minus<WORD>(), static_cast<WORD>(TByteBuffer::MaxCapacity)),
														  fnc_ext::compose1(fnc_ext::get_mem_func_ref(&TThisClass::TByteBuffer::length),
																			fnc_ext::get_mem(&TThisClass::_receivedBuffer))))),
//										fnc_ext::get_mem_func(&TThisClass::FreeBufferSpace))),
		DataByPackets, DataByLength, "Switch If Need Receive Packets" );
 
 
            
         
             Говногость,
            04 Сентября 2013 Говногость,
            04 Сентября 2013
 
- 
        
        
                +13         
                            - 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
- 46
- 47
- 48
- 49
- 50
- 51
- 52
 void User::AddFriend(User& newFriend)
{
    friends_.push_back(&newFriend);
    pDB_->AddFriend(GetName(), newFriend.GetName());
}
//...VS...
void User::AddFriend(User& newFriend)
{
    friends_.push_back(&newFriend);
    try
    {
        pDB_->AddFriend(GetName(), newFriend.GetName());
    }
    catch (...)
    {
        friends_.pop_back();
        throw;
    }
}
//...VS...
class VectorInserter//Глобальный безопасный вектороВставлятель.
{
public:
    VectorInserter(std::vector<User*>& v, User& u)
    : container_(v), commit_(false)
    {
        container_.push_back(&u);
    }
    void Commit() throw()
    {
        commit_ = true;
    }
    ~VectorInserter()
    {
        if (!commit_) container_.pop_back();
    }
private:
    std::vector<User*>& container_;
    bool commit_;
};
void User::AddFriend(User& newFriend)
{
    VectorInserter ins(friends_, &newFriend);
    pDB_->AddFriend(GetName(), newFriend.GetName());
    // Everything went fine, commit the vector insertion
    ins.Commit();
}
 
 
            
         
             LispGovno,
            03 Сентября 2013 LispGovno,
            03 Сентября 2013
 
- 
        
        
                +8         
                            - 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
 template<int ID> struct typeof_access
{
    struct id2type; //not defined
};
template<class T, int ID> struct typeof_register : typeof_access
{
    // define base's nested class here
    struct typeof_access::id2type
    {
        typedef T type;
    };
};
//Type registration function 
typeof_register<T, compile-time-constant> register_type(const T&);
//Actually register type by instantiating typeof_register for the correct type
sizeof(register_type(some-type));
//Use the base class to access the type.
typedef typeof_access::id2type::type type;
 
 
            Igor Chesnokov discovered a method that allows to implement typeof on the VC series of compilers. It uses a bug in the Microsoft compiler that allows a nested class of base to be defined in a class derived from base.
 
 http://www.boost.org/doc/libs/1_54_0/doc/html/typeof/other.html
 
             LispGovno,
            03 Сентября 2013 LispGovno,
            03 Сентября 2013
 
- 
        
        
                +14         
                            - 1
- 2
 struct Ziga : std::exception {};
throw Ziga();
 
 
            Теперь вы знаете как кинуть зигу в C++ !!
         
             PSIAlt,
            02 Сентября 2013 PSIAlt,
            02 Сентября 2013
 
- 
        
        
                −16         
                            - 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
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
 #include <iostream>
#include <string>
using namespace std;
/*
*/
int change_word(const int begin_pos, string &words, int k, char c)
{
    int pos = begin_pos;
    int char_count = 0;
    bool replaced = false; 
    while(pos < words.length() && isalpha(words[pos]))
    {
        char_count++;
        if(char_count == k && !replaced)
        {
            words[pos] = c;
            replaced = true;
        }
        pos++;
    }
    return pos; 
}
void change_words(string &words, int k, char c)
{
    int i = 0;
    while(i < words.length())
    {
        if(isalpha(words[i]))
        {
            i = change_word(i, words, k, c);
        }
        else
        {
            i++;
        }
    }
}
int main()
{
    char c = '>'; 
    int k = 0; 
    string words = "Length of the substring to be copied";
    cout << "enter number:";
    cin >> k;
    change_words(words, k, c);
    cout << "changed text: " << words << endl;
    return 0;
}
 
 
            лаба на с++, заменить в тексте к-тую букву на символ с.
         
             spivti,
            01 Сентября 2013 spivti,
            01 Сентября 2013
 
- 
        
        
                +12         
                            - 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
 // Вопрос: как сгенерировать в рантайме предупреждение от компилятора?
// http://stackoverflow.com/q/4187967
   void f(int*p = nullptr)
    {
    if (!p)
{
//HERE I WOULD LIKE TO HAVE AN MSG THAT WOULD BE DISPLAYED DURING COMPILATION AS A WARNING POSSIBLY
}
    }
// Ответ: очевидно же, вызвать компилятор для соответствующего кода.
// http://stackoverflow.com/a/4188155
void f(int *p = nullptr) {
    if (!p) {
        system("gcc -Wall warning.c");
    }
}
 
 
            Каков вопрос - таков ответ.
         
             Xom94ok,
            01 Сентября 2013 Xom94ok,
            01 Сентября 2013
 
- 
        
        
                +64         
                            - 1
- 2
- 3
- 4
- 5
- 6
- 7
 Товарищи, стоит задача: найти количество слов в строке.
 Автор  (http://programmersforum.ru/showthread.php?p=1269850#post1269850) просто делит строку по пробелам, затем
подсчитывает кол-во слов.
Я же,  говорю, что такой подход НЕПРАВИЛЕН,  т.к. в русском
языке (да и не только) слова разделяются символами пунктуации, которые сами в состав слова не входят - следовательно, делить нужно по ним: 
 [code]" ' . , ! ?: ;  -  + <пробел> <табуляция> ( )[code]
 На меня сразу же наехали и поудаляли мои сообщения. Неужели я не прав?
 
 
            Баян все еще там: http://programmersforum.ru/showthread.php?p=1269850#post1269850
         
             Stertor,
            28 Августа 2013 Stertor,
            28 Августа 2013
 
- 
        
        
                +15         
                            - 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
 #include <cstdio>
#include <cstdlib>
#include <fstream>
// #include <cstring>
#include <string>
using namespace std;
string exec = "\"c:\\Program Files (x86)\\GnuWin32\\bin\\wget.exe\"";
string root = "http://techno.org/electronic-music-guide/";
const char* flist = "list.txt";
void getFile(string name)
{
	string command = exec + " " + root + name;
	system(command.c_str());
}
int main(int argc, char* argv[])
{
	ifstream fin(flist);
	string name = "";
	while(true)
	{
		if (fin.eof()) break;
		getline(fin, name);
		getFile(name);
	}
	return 0;
}
 
 
            Суть такова: ваш покорный слуга копался в исходниках этого: http://techno.org/electronic-music-guide/ -- ради музыкальных лупов на рингтон. Узнал, что это реализовано swf-модулями, список которых он добыл после объединения кучи скриптов и сортировки в NPP. Осталось лишь найти способ загрузить эти файлы по списку.
 Но искать было лень, поэтому реализовано подручными средствами: мозгом, компилятором и случайно попавшимся wget'ом (FTW).
 
             ckopo,
            28 Августа 2013 ckopo,
            28 Августа 2013
 
- 
        
        
                +23         
                            - 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
 void main()
{
	// Откуда в программе баги берутся???
	struct ╯°□°{}╯︵┻━┻;
	// Понятия не имею.
	// Код классный, имена переменных говорят сами за себя...
	// Строк комментариев больше, чем строк кода...
	// А баги всё-равно есть.
	// КАК ЖЕ МЕНЯ ВСЁ ЭТО БЕСИТ!
	(╯°□°)╯︵┻━┻;
}
 
 
            В ответ цитате с баша:
 
 scala самый крутой язык, в нём можно столами кидаться
 def ┻━━┻ = {
 new Exception("ACHTUNG!")
 }
 throw ┻━━┻
 
 На С/С++ тоже можно столами кидаться и более красиво! Достаточно сохранение файла в unicode включить.
 
             Little-Horny,
            25 Августа 2013 Little-Horny,
            25 Августа 2013