[ 
https://issues.apache.org/jira/browse/PROTON-1138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15168118#comment-15168118
 ] 

ASF subversion and git services commented on PROTON-1138:
---------------------------------------------------------

Commit c7f3f558511ed07b8972304a2ba7a69dfc6b6354 in qpid-proton's branch 
refs/heads/master from [~aconway]
[ https://git-wip-us.apache.org/repos/asf?p=qpid-proton.git;h=c7f3f55 ]

PROTON-1138: Simplify comparable class, make comparable inheritance private.

Simplified the comparable class.

- comparable<T> is a private empty base class that exists only to instantiate 
operator friends of T.
- comparable<T> is never used in any other way.
- for any compiler with even rudimentary empty-base-class support, this has 0 
run-time overhead.

I did some research to try and eliminate inheritance entirely. There are 2 well
known approaches.

1. boost::operators uses exactly the approach above.
2. std::rel_ops uses unconstrained templates that match anything with op == or 
< operator, we already agreed that approach is unsuitable for public API.

I tried type-trait approaches but could not find one that was better than the
above.  IMO inheritance is the right fit: It has no run-time overhead, it is
easy to understand, and we *want* "is-a" inheritance semantics: if `object` is
comparable then sub-classes of `object` should be comparable. (That is the part
that is hard to achieve with type-traits. When I realized I was trying to
reinvent inheritance I decided to let go.)


> Assorted C++ API cleanups
> -------------------------
>
>                 Key: PROTON-1138
>                 URL: https://issues.apache.org/jira/browse/PROTON-1138
>             Project: Qpid Proton
>          Issue Type: Improvement
>          Components: cpp-binding
>    Affects Versions: 0.13.0
>            Reporter: Justin Ross
>            Assignee: Justin Ross
>             Fix For: 0.13.0
>
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to