[Review] Boost.Type Traits Extension by Frederic Bron

This is my review of the Boost Type Traits Extension by Frederick Brron. * What is your evaluation of the design? The design is very straightforward, and easy to use. Although I do not anticipate the need to check the return from the operator traits I am glad that is part of the library. The only suggestion I would like to make regarding the design is in the default argument for the return value, which tells the implementation not to check for the return value. While it is wildly improbable that any user of the operator traits would actually want to have a trait whose return is actually 'void', it is still theoretically possible. Therefore I think that the default for the return value, which means to not check for the return value, should be an unspecified marker type in the type_traits::detail namespace. It is a convention of all Boost libraries that any library's detail namespace is to be used only by the implementation of that library and not by a user of that library. So using an unspecified marker type in the type traits detail namespace should be fine. * What is your evaluation of the implementation? I did not look at the source code. I do have a large reservation from reading the documentation, so let me explain it now. The ideal situation when using template metaprogramming constructs, such as the type traits operators metafunctions, is that an instantiation of the metafunction should never produce a compiler error. This is particularly true of metafunctions which return a boolean constant value, since the boolean value can encapsulate the notion of true or false when using the metafunction based on input types. Of course it may be the nature of C++ that this ideal situation can not be met. But then the user of the metafunction has to be able to instruct his end-users about whatever limitation exists and make allowance for it. In the type traits operators library there are documented two major situations where the use of a type will produce a compiler error and not just a false boolean constant value. This is a painful situation. I realize these two situations are fully documented in the "Known Issues" area of the Operator Type Traits documentation. But now let us take a look at the template metaprogrammer who wishes to use some subset of the type traits operators in his own library based on a type his end-user may pass to him. What this programmer wishes to do is to use a type traits operator if a type passed to him supports it, otherwise not use the operator at all. Unfortunately the end-user of that library passes a type which may or may not support such functionality, not knowing that the type will trigger a compiler error because the type traits operators are being used internally and some known issues exist which that type encompasses. What that template metaprogrammer must then do is to add another template parameter to his template, and documentation which explains to his end-user the specific situations whch trigger compiler errors in the type traits operators, that if a type is being passed which could cause the type traits compiler error conditions he must set this other parameter to false so that the compiler error can be avoided. This is a difficult way to program metafunctions successfully. So it is very disappointing that these "Known Issues" exist and it would be very worthwhile if a way could be found around them, by something different in the internal implementation, if that were possible. * What is your evaluation of the documentation? The documentation is thorough and complete. * What is your evaluation of the potential usefulness of the library? I think it is very useful. * Did you try to use the library? With what compiler? Did you have any problems? Tested with VC 8,9,10 and everything worked as expected. I have also integrated into another library on which I am working and that was successful also. * How much effort did you put into your evaluation? A glance? A quick reading? In-depth study? I read the docs, tested the library under Windows, and tried it in my own library, so it was pretty thorough. * Are you knowledgeable about the problem domain? Yes. And finally, every review should answer this question: * Do you think the library should be accepted as a Boost library? Be sure to say this explicitly so that your other comments don't obscure your overall opinion. I vote for the library to be accepted into Boost. I would also like to see if the "Known Issues" could not be solved, not necessarily by the author of the library who has put so much effort and work into it, but possibly by other Boost experts who might find some solution to these issues which mar the library somewhat for me. But even if these issues could never be solved the library is worthwhile enough to be accepted. Edward Diener

The only suggestion I would like to make regarding the design is in the default argument for the return value, which tells the implementation not to check for the return value. While it is wildly improbable that any user of the operator traits would actually want to have a trait whose return is actually 'void', it is still theoretically possible. Therefore I think that the default for the return value, which means to not check for the return value, should be an unspecified marker type in the type_traits::detail namespace. It is a convention of all Boost libraries that any library's detail namespace is to be used only by the implementation of that library and not by a user of that library. So using an unspecified marker type in the type traits detail namespace should be fine.
Good news for the return type of operators: I have been able to check for exact void return and have default "dont_care": template< class LHS, class RHS=LHS, class RET=dont_care > has_operator_plus; 1. operator+(A, A) exists and returns void has_operator_plus<A, A>::value -> true (dont check return type) has_operator_plus<A, A, void>::value -> true (check for exact void return type) has_operator_plus<A, A, R>::value -> false (void!=R) 2. operator+(A, A) exists and returns R!=void has_operator_plus<A, A>::value -> true (dont check return type) has_operator_plus<A, A, void>::value -> false (void!=R) has_operator_plus<A, A, R>::value -> true (void!=R) 3. operaot+(A, A) does not exist has_operator_plus<A, A>::value -> false has_operator_plus<A, A, void>::value -> false has_operator_plus<A, A, R>::value -> false I think this is now much better. Frédéric

Frédéric Bron wrote:
Good news for the return type of operators: I have been able to check for exact void return and have default "dont_care":
template< class LHS, class RHS=LHS, class RET=dont_care > has_operator_plus;
1. operator+(A, A) exists and returns void
has_operator_plus<A, A>::value -> true (dont check return type) has_operator_plus<A, A, void>::value -> true (check for exact void return type) has_operator_plus<A, A, R>::value -> false (void!=R)
2. operator+(A, A) exists and returns R!=void
has_operator_plus<A, A>::value -> true (dont check return type) has_operator_plus<A, A, void>::value -> false (void!=R) has_operator_plus<A, A, R>::value -> true (void!=R)
3. operaot+(A, A) does not exist
has_operator_plus<A, A>::value -> false has_operator_plus<A, A, void>::value -> false has_operator_plus<A, A, R>::value -> false
I think this is now much better.
Could you make the same analysis with "const, volatile and references", as parameter and return type? Thanks, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/Review-Boost-Type-Traits-Extension-by-Fre... Sent from the Boost - Dev mailing list archive at Nabble.com.

Could you make the same analysis with "const, volatile and references"
I must answer in html. cv qualifiers work just fine. In the implementation, I have removed the reference qualifier from the analysis when I added the +=, -=, ... operators because they require lvalue as left hand side parameter (so I first remove the & if it exists and then I add it to make sure I have an lvalue). This makes <cv A> and <cv A&> behave the same. I am checking if I can handle this better. operator+(A) operator+(const A) operator+(volatile A) operator+(const volatile A) operator+(A&) operator+(const A&) operator+(volatile A&) operator+(const volatile A&) has_operator_unary_plus<A> true true true true true true true true has_operator_unary_plus<const A> true true true true false true false true has_operator_unary_plus<volatile A> true true true true false false true true has_operator_unary_plus<const volatile A> true true true true false false false true has_operator_unary_plus<A&> true true true true true true true true has_operator_unary_plus<const A&> true true true true false true false true has_operator_unary_plus<volatile A&> true true true true false false true true has_operator_unary_plus<const volatile A&> true true true true false false false true Frédéric

Could you make the same analysis with "const, volatile and references" I must answer in html. cv qualifiers work just fine. In the implementation, I have removed the reference qualifier from the analysis when I added the +=, -=, ... operators because they require lvalue as left hand side parameter (so I first remove the & if it exists and then I add it to make sure I have an lvalue). This makes <cv A> and <cv A&> behave the same. I am checking if I can handle
I am not sure of the formatting of the table you received because I received it in text mode, not html, so let me retry (sorry for this). this better. operator+(A) operator+(const A) operator+(volatile A) operator+(const volatile A) operator+(A&) operator+(const A&) operator+(volatile A&) operator+(const volatile A&) has_operator_unary_plus<A> true true true true true true true true has_operator_unary_plus<const A> true true true true false true false true has_operator_unary_plus<volatile A> true true true true false false true true has_operator_unary_plus<const volatile A> true true true true false false false true has_operator_unary_plus<A&> true true true true true true true true has_operator_unary_plus<const A&> true true true true false true false true has_operator_unary_plus<volatile A&> true true true true false false true true has_operator_unary_plus<const volatile A&> true true true true false false false true Frédéric

Frédéric Bron wrote:
Could you make the same analysis with "const, volatile and references" I must answer in html. cv qualifiers work just fine. In the implementation, I have removed the reference qualifier from the analysis when I added the +=, -=, ... operators because they require lvalue as left hand side parameter (so I first remove the & if it exists and
I am not sure of the formatting of the table you received because I received it in text mode, not html, so let me retry (sorry for this). then I add it to make sure I have an lvalue). This makes and behave the same. I am checking if I can handle this better.
operator+(A) operator+(const A) operator+(volatile A) operator+(const volatile A) operator+(A&) operator+(const A&) operator+(volatile A&) operator+(const volatile A&) has_operator_unary_plus true true true true true true true true has_operator_unary_plus true true true true false true false true has_operator_unary_plus true true true true false false true true has_operator_unary_plus true true true true false false false true has_operator_unary_plus<A&> true true true true true true true true has_operator_unary_plus true true true true false true false true has_operator_unary_plus true true true true false false true true has_operator_unary_plus true true true true false false false true
Thanks, this will make cleared the documentation. What about the return type? Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/Review-Boost-Type-Traits-Extension-by-Fre... Sent from the Boost - Dev mailing list archive at Nabble.com.
participants (3)
-
Edward Diener
-
Frédéric Bron
-
Vicente Botet