From 2370288a79f29c5c51c3480d03fc7c4597ff88b0 Mon Sep 17 00:00:00 2001
From: jzmaddock
Date: Mon, 21 Nov 2022 18:24:04 +0000
Subject: [PATCH] Update operators docs. Fixes
https://github.com/boostorg/type_traits/issues/160.
---
.../category/value_traits/operators.html | 35 ++++++++++++-------
doc/html/index/s11.html | 2 +-
doc/html/index/s12.html | 2 +-
doc/html/index/s13.html | 2 +-
doc/html/index/s14.html | 2 +-
doc/operators.qbk | 12 ++++---
6 files changed, 34 insertions(+), 21 deletions(-)
diff --git a/doc/html/boost_typetraits/category/value_traits/operators.html b/doc/html/boost_typetraits/category/value_traits/operators.html
index 588467d..e52ab9b 100644
--- a/doc/html/boost_typetraits/category/value_traits/operators.html
+++ b/doc/html/boost_typetraits/category/value_traits/operators.html
@@ -1148,7 +1148,15 @@
All traits are implemented the same way using preprocessor macros to avoid
code duplication. The main files are in boost/type_traits/detail
:
has_binary_operator.hpp
, has_prefix_operator.hpp
- and has_postfix_operator.hpp
. The example of prefix
+ and has_postfix_operator.hpp
.
+
+
+ Given a sufficiently conforming C++11 compiler, these traits are implemented
+ in a rather compact and straightforward way that should always give accurate
+ answers.
+
+
+ In C++03 there is a legacy implementation, by way of example the prefix
operator-
is presented below:
@@ -1324,7 +1332,7 @@
Limitation
-
- Requires a compiler with working SFINAE.
+ Prior to C++11, requires a compiler with working SFINAE.
@@ -1333,21 +1341,22 @@
-
- These traits cannot detect whether the operators are public or not:
- if an operator is defined as a private member of type
T
then the instantiation of the corresponding
- trait will produce a compiler error. For this reason these traits cannot
- be used to determine whether a type has a public operator or not.
+ Prior to C++11, these traits cannot detect whether the operators are
+ public or not: if an operator is defined as a private member of type
+ T
then the instantiation
+ of the corresponding trait will produce a compiler error. For this
+ reason these traits cannot be used to determine whether a type has
+ a public operator or not.
struct A { private: A operator-(); };
boost::has_unary_minus<A>::value;
-
- There is an issue if the operator exists only for type
A
and B
- is convertible to A
.
- In this case, the compiler will report an ambiguous overload because
- both the existing operator and the one we provide (with argument of
- type any
) need type
- conversion, so that none is preferred.
+ Prior to C++11, there is an issue if the operator exists only for type
+ A
and B
is convertible to A
. In this case, the compiler will
+ report an ambiguous overload because both the existing operator and
+ the one we provide (with argument of type any
)
+ need type conversion, so that none is preferred.
struct A { };
void operator-(const A&);
struct B { operator A(); };
@@ -1388,7 +1397,7 @@
class bad { };
class good { };
-bool f(const good&, const good&) { }
+bool f(const good&, const good&) { return true; }
int main() {
std::cout<<std::boolalpha;
diff --git a/doc/html/index/s11.html b/doc/html/index/s11.html
index 55d5c81..98bc5ae 100644
--- a/doc/html/index/s11.html
+++ b/doc/html/index/s11.html
@@ -24,7 +24,7 @@
A C D E F H I M N O P R T
-
diff --git a/doc/html/index/s12.html b/doc/html/index/s12.html
index e35106f..c1de26b 100644
--- a/doc/html/index/s12.html
+++ b/doc/html/index/s12.html
@@ -24,7 +24,7 @@
F R T V
-
diff --git a/doc/html/index/s13.html b/doc/html/index/s13.html
index 12e43cb..7b8a852 100644
--- a/doc/html/index/s13.html
+++ b/doc/html/index/s13.html
@@ -24,7 +24,7 @@
B
-
diff --git a/doc/html/index/s14.html b/doc/html/index/s14.html
index d516966..fb56f32 100644
--- a/doc/html/index/s14.html
+++ b/doc/html/index/s14.html
@@ -23,7 +23,7 @@
A B C D E F H I M N O P R T U V
-
diff --git a/doc/operators.qbk b/doc/operators.qbk
index 67b3f07..435c148 100644
--- a/doc/operators.qbk
+++ b/doc/operators.qbk
@@ -247,7 +247,11 @@ All traits are implemented the same way using preprocessor macros to avoid code
duplication.
The main files are in [^boost/type_traits/detail]: [^has_binary_operator.hpp],
[^has_prefix_operator.hpp] and [^has_postfix_operator.hpp].
-The example of prefix `operator-` is presented below:
+
+Given a sufficiently conforming C++11 compiler, these traits are implemented in a rather
+compact and straightforward way that should always give accurate answers.
+
+In C++03 there is a legacy implementation, by way of example the prefix `operator-` is presented below:
``
namespace boost {
@@ -416,11 +420,11 @@ struct has_unary_minus : ::boost::integral_constant::value; // error: A::operator-() is private
``
-* There is an issue if the operator exists only for type `A` and `B` is
+* Prior to C++11, there is an issue if the operator exists only for type `A` and `B` is
convertible to `A`. In this case, the compiler will report an ambiguous overload
because both the existing operator and the one we provide (with argument of type
`any`) need type conversion, so that none is preferred.