Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/andreasfertig/programming-with-cpp20
/ divide
Function
divide
12.04-constexprThrow0/main.cpp:7–15 ·
view source on GitHub ↗
Source
from the content-addressed store, hash-verified
5
#include <stdexcept>
6
7
constexpr double divide(int a, int b)
8
{
9
if(0 == b) {
10
// #A If not 0 at compile-time, it is fine
11
throw std::overflow_error(
"Divide by zero"
);
12
}
13
14
return a / b;
15
}
16
17
int main()
18
{
Callers
1
main
Function · 0.85
Calls
no outgoing calls
Tested by
no test coverage detected