mirror of
https://github.com/cpp-best-practices/cppbestpractices.git
synced 2025-12-17 11:14:35 +03:00
Merge pull request #73 from arunksaha/constexpr
static constant floating point use constexpr
This commit is contained in:
@@ -16,7 +16,7 @@ namespace my_project {
|
|||||||
// if the above macro would be expanded, then the following line would be:
|
// if the above macro would be expanded, then the following line would be:
|
||||||
// static const double 3.14159 = 3.14159;
|
// static const double 3.14159 = 3.14159;
|
||||||
// which leads to a compile-time error. Sometimes such errors are hard to understand.
|
// which leads to a compile-time error. Sometimes such errors are hard to understand.
|
||||||
static const double PI = 3.14159;
|
static constexpr double PI = 3.14159;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user