terminate
Exit the program.
Synopsis
Declared in header <terminate.cpp>
void
terminate() noexcept;
Description
The program will end immediately.
Note
|
This function does not return. |
MrDocs is a C++ documentation generator for your projects.
No workarounds: A tool that fully understands C++
Mr. Docs takes a specially formatted comment, called a Javadoc, which precedes a C++ declaration and renders it to form a reference as part of documentation.
Mr. Docs understands C++: Overload sets, private APIs, Concepts and constraints, unspecified return types, aliases, constants, SFINAE, hidden base classes, niebloids, and coroutines.
Choose from multiple output formats: Asciidoc, HTML, or XML.
Mr. Docs is highly customizable. You can change the output format, the theme, and even the way the documentation is generated.
Boost.URL Antora documentation.
Boost.URL multi-page Asciidoc documentation.
Boost.URL single-page Asciidoc documentation.
Boost.URL single-page HTML documentation.
Boost.URL XML documentation.
Boost.Scope multi-page Asciidoc documentation.
Boost.Scope single-page Asciidoc documentation.
/** Exit the program.
The program will end immediately.
@note This function does not return.
*/
[[noreturn]]
void
terminate() noexcept;
Exit the program.
Declared in header <terminate.cpp>
void
terminate() noexcept;
The program will end immediately.
Note
|
This function does not return. |
/** Return the distance between two points
This function returns the distance between two points
according to the Euclidean distance formula.
@param x0 The x-coordinate of the first point
@param y0 The y-coordinate of the first point
@param x1 The x-coordinate of the second point
@param y1 The y-coordinate of the second point
@return The distance between the two points
*/
double
distance(double x0, double y0, double x1, double y1);
Return the distance between two points
Declared in header <distance.cpp>
double
distance(
double x0,
double y0,
double x1,
double y1);
This function returns the distance between two points according to the Euclidean distance formula.
The distance between the two points
Name | Description |
---|---|
x0 |
The x-coordinate of the first point |
y0 |
The y-coordinate of the first point |
x1 |
The x-coordinate of the second point |
y1 |
The y-coordinate of the second point |
/** Return true if a number is prime.
@par Complexity
Linear in n.
@return Whether or not n is prime.
@param n The number to test
*/
bool
is_prime(unsigned long long n) noexcept;
Return true if a number is prime.
Declared in header <is_prime.cpp>
bool
is_prime(unsigned long long n) noexcept;
Linear in n.
Whether or not n is prime.
Name | Description |
---|---|
n |
The number to test |
#include <type_traits>
#include <stdexcept>
/** Computes the square root of an integral value.
This function calculates the square root of a
given integral value using bit manipulation.
@throws std::invalid_argument if the input value is negative.
@tparam T The type of the input value. Must be an integral type.
@param value The integral value to compute the square root of.
@return The square root of the input value.
*/
template <typename T>
std::enable_if_t<std::is_integral_v<T>, T> sqrt(T value) {
if (value < 0) {
throw std::invalid_argument(
"Cannot compute square root of a negative number");
}
T result = 0;
// The second-to-top bit is set
T bit = 1 << (sizeof(T) * 8 - 2);
while (bit > value) bit >>= 2;
while (bit != 0) {
if (value >= result + bit) {
value -= result + bit;
result += bit << 1;
}
result >>= 1;
bit >>= 2;
}
return result;
}
Computes the square root of an integral value.
Declared in header <sqrt.cpp>
template<typename T>
T
sqrt(T value);
This function calculates the square root of a given integral value using bit manipulation.
Name | Thrown on |
---|---|
|
the input value is negative. |
The square root of the input value.
Name | Description |
---|---|
T |
The type of the input value. Must be an integral type. |
Name | Description |
---|---|
value |
The integral value to compute the square root of. |
Give us a Star on GitHub: