Created
November 26, 2016 15:59
-
-
Save illescasDaniel/55dddcd9a8d1682d6b48c9859cd7cc0e to your computer and use it in GitHub Desktop.
Assert [C++]
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> | |
| #include <cassert> | |
| using namespace std; | |
| int main(int argc, char *argv[]) { | |
| uint16_t number1 = 10, number2 = 20; | |
| assert(number1 + number2 == 30); | |
| // Expression is evaluated at compile time | |
| constexpr int number3 = 5, number4 = 6; | |
| static_assert(number4 - number3 == 1, "Error"); // Expression must be const / constexpr | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment