mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Update CppCoreGuidelines.md
This commit is contained in:
parent
05c44d23ab
commit
17f76d0258
|
@ -16243,7 +16243,7 @@ and should be used only as building blocks for meaningful concepts, rather than
|
|||
template<typename T>
|
||||
concept Addable = has_plus<T>; // bad; insufficient
|
||||
|
||||
template<Addable N> auto plus(const N& a, const N& b) // use two numbers
|
||||
template<Addable N> auto algo(const N& a, const N& b) // use two numbers
|
||||
{
|
||||
// ...
|
||||
return a + b;
|
||||
|
@ -16273,7 +16273,7 @@ The ability to specify a meaningful semantics is a defining characteristic of a
|
|||
&& has_multiply<T>
|
||||
&& has_divide<T>;
|
||||
|
||||
template<Number N> auto plus(const N& a, const N& b) // use two numbers
|
||||
template<Number N> auto algo(const N& a, const N& b) // use two numbers
|
||||
{
|
||||
// ...
|
||||
return a + b;
|
||||
|
@ -16281,11 +16281,11 @@ The ability to specify a meaningful semantics is a defining characteristic of a
|
|||
|
||||
int x = 7;
|
||||
int y = 9;
|
||||
auto z = plus(x, y); // z = 18
|
||||
auto z = algo(x, y); // z = 18
|
||||
|
||||
string xx = "7";
|
||||
string yy = "9";
|
||||
auto zz = plus(xx, yy); // error: string is not a Number
|
||||
auto zz = algo(xx, yy); // error: string is not a Number
|
||||
|
||||
##### Note
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user