1. Список говнокодов пользователя nullptr

    Всего: 1

  2. C++ / Говнокод #22863

    −15

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    /* a temporary boolean true value which changes the value of the referenced boolean variable to 
    	true and to false on destruction, meant to be used for short-lived boolean changes*/
    class tempTrue {
    bool & bVal;
    public:
    	tempTrue(bool & ref):bVal(ref){bVal = true;}
    	virtual ~tempTrue() { bVal = false; }
    	void toggle() { bVal = !bVal; }
    };
    
    class tempFalse {
    bool & bVal;
    public:
    	tempFalse(bool & ref):bVal(ref){bVal = false;}
    	virtual ~tempFalse() { bVal = true; }
    	void toggle() { bVal = !bVal; }
    };
    
    class tempToggle {
    bool & bVal;
    public:
    	tempToggle(bool & ref): bVal(ref){ bVal = !bVal;}
    	virtual ~tempToggle() { bVal = !bVal; }
    };
    
    
    class booleanInit {
    public:
    	booleanInit(bool b):bVal(b) {}
    	operator bool & () { return bVal; }
    	operator const bool & () const { return bVal; }
    private:
    	bool bVal;
    };
    
    
    class booleanTrue:public booleanInit {
    public:
    	booleanTrue():booleanInit(true) {}
    };
    
    class booleanFalse:public booleanInit {
    public:
    	booleanFalse():booleanInit(false) {}
    };

    когда узнал про RAII

    nullptr, 27 Апреля 2017

    Комментарии (179)