It can be a nuisance to define all operators, but not hard.
Hopefully, C++17 will give you comparison operators by default.
##### Enforcement
???
* Flag classes the support "odd" subsets of a set of operators, e.g., `==` but not `!=` or `+` but not `-`.
Yes, `std::string` is "odd", but it's too late to change that.
### <aname="Rt-alias"></a>T.42: Use template aliases to simplify notation and hide implementation details
@ -12042,29 +12096,74 @@ Flag uses where an explicitly specialized type exactly matches the types of the
##### Reason
???
Readability.
Preventing surprises and errors.
Most uses support that anyway.
##### Example
???
class X {
// ...
public:
explicit X(int);
X(const X&); // copy
X operator=(const X&);
X(X&&); // move
X& operator=(X&&);
~X();
// ... no moreconstructors ...
};
X x {1}; // fine
X y = x; // fine
std::vector<X> v(10); // error: no default constructor
##### Note
Semiregular requires default constructible.
##### Enforcement
???
* Flag types that are not at least `SemiRegular`.
### <aname="Rt-visible"></a>T.47: Avoid highly visible unconstrained templates with common names
##### Reason
???
An unconstrained template argument is a perfect match for anything so such a template can be preferred over more specific types that require minor conversions.
This is particularly annoying/dangerous when ADL is used.
bool operator==(int, Bad::S) { cout << "T0\n"; return true; } // compate to int
void test()
{
Bad::S bad{ 1 };
vector<int> v(10);
bool b = 1==bad;
bool b2 = v.size()==bad;
}
}
This prints `T0` and `Bad`.
Now the `==` in `Bad` was designed to cause trouble, but would you have spotted the problem in real code?
The problem is that `v.size()` returns an `unsigned` integer so that a conversion is needed to call the local `==`;
the `==` in `Bad` requires no conversions.
Realistic types, such as the standard library iterators can be made to exhibit similar anti-social tendencies.
##### Enforcement
???
????
### <aname="Rt-concept-def"></a>T.48: If your compiler does not support concepts, fake them with `enable_if`
@ -12295,6 +12394,35 @@ When `concept`s become available such alternatives can be distinguished directly
???
### <aname="Rt-specialization2"></a>T.67: Use specialization to provide alternative implementations for irregular types
##### Reason
???
##### Example
???
##### Enforcement
???
### <aname="Rt-cast"></a>T.68: Use `{}` rather than `()` within templates to avoid ambiguities
##### Reason
???
##### Example
???
##### Enforcement
???
### <aname="Rt-customization"></a>T.69: Inside a template, don't make an unqualified nonmember function call unless you intend it to be a customization point