mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge pull request #877 from cubbimew/travis-fixes-3-30-17
travis fixes
This commit is contained in:
commit
a516bfe7e7
|
@ -1868,9 +1868,13 @@ Having many arguments opens opportunities for confusion. Passing lots of argumen
|
||||||
|
|
||||||
The two most common reasons why functions have too many parameters are:
|
The two most common reasons why functions have too many parameters are:
|
||||||
|
|
||||||
1. *Missing an abstraction.* There is an abstraction missing, so that a compound value is being passed as individual elements instead of as a single object that enforces an invariant. This not only expands the parameter list, but it leads to errors because the component values are no longer protected by an enforced invariant.
|
1. *Missing an abstraction.* There is an abstraction missing, so that a compound value is being
|
||||||
|
passed as individual elements instead of as a single object that enforces an invariant.
|
||||||
|
This not only expands the parameter list, but it leads to errors because the component values
|
||||||
|
are no longer protected by an enforced invariant.
|
||||||
|
|
||||||
2. *Violating "one function, one responsibility."* The function is trying to do more than one job and should probably be refactored.
|
2. *Violating "one function, one responsibility."* The function is trying to do more than one
|
||||||
|
job and should probably be refactored.
|
||||||
|
|
||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
|
@ -17755,7 +17759,7 @@ Pointers should only refer to single objects, and pointer arithmetic is fragile
|
||||||
|
|
||||||
int n = a[0]; // OK
|
int n = a[0]; // OK
|
||||||
|
|
||||||
span<int> q = a.subspan(1); // OK
|
span<int> q = a.subspan(1); // OK
|
||||||
|
|
||||||
if (a.length() < 6) return;
|
if (a.length() < 6) return;
|
||||||
|
|
||||||
|
@ -17836,7 +17840,7 @@ Dynamic accesses into arrays are difficult for both tools and humans to validate
|
||||||
void f1a()
|
void f1a()
|
||||||
{
|
{
|
||||||
int arr[COUNT];
|
int arr[COUNT];
|
||||||
span<int,COUNT> av = arr;
|
span<int, COUNT> av = arr;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto& e : av)
|
for (auto& e : av)
|
||||||
e = i++;
|
e = i++;
|
||||||
|
|
|
@ -508,6 +508,7 @@ UB
|
||||||
unaliased
|
unaliased
|
||||||
uncompromised
|
uncompromised
|
||||||
undetached
|
undetached
|
||||||
|
unencapsulated
|
||||||
unenforceable
|
unenforceable
|
||||||
uninit
|
uninit
|
||||||
uniqueptrparam
|
uniqueptrparam
|
||||||
|
|
Loading…
Reference in New Issue
Block a user