Created
          July 13, 2015 12:50 
        
      - 
      
- 
        Save krysseltillada/78ff6cbe7a1da1b90f66 to your computer and use it in GitHub Desktop. 
    constexpr constructors
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include <iostream> | |
| class Debug { | |
| public: | |
| constexpr Debug (bool a, bool b, bool c): | |
| hw (a), io (b), other (c) { } | |
| constexpr Debug() : Debug(false, false, false) { } | |
| constexpr Debug (bool aa) : Debug (false , false ,false) { } | |
| constexpr Debug (bool aaa, bool bb) : Debug (false, false, false) { } | |
| void set_io (bool); | |
| bool set_any (); | |
| void set_other (bool); | |
| void set_hw (bool); | |
| private: | |
| bool hw, io, other; | |
| }; | |
| void Debug::set_hw (bool bbbb) { | |
| this->hw = bbbb; | |
| } | |
| void Debug::set_io (bool b) { | |
| this->io = b; | |
| } | |
| bool Debug::set_any () { | |
| return hw || io || other; | |
| } | |
| void Debug::set_other (bool bbb) { | |
| this->other = bbb; | |
| } | |
| int main () | |
| { | |
| Debug test (true, true, true); | |
| if (test.set_any()) | |
| std::cerr << "prints error (need debugging)" << std::endl; | |
| else | |
| std::cerr << "doesnt need debug" << std::endl; | |
| return 0; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment