Code Monkey home page Code Monkey logo

Comments (6)

joaquintides avatar joaquintides commented on July 17, 2024 1

Thank you! Some Russian guy is going to be grateful for this, even if he is not aware of the behind-the-scenes conversation.

from utility.

d-frey avatar d-frey commented on July 17, 2024

Looking at the documentation at http://www.boost.org/doc/libs/1_65_1/libs/utility/operators.htm#deref, it is documented to return &*i, which must be convertible to P. Given that the library is quite old and it has been like that for >=15 years, I wonder if there really is a problem that needs to be fixed. Plus we would add a dependency. What are your thoughts on this? Or do you have a specific problem that needs fixing?

from utility.

joaquintides avatar joaquintides commented on July 17, 2024

Hi Daniel,

It's a real problem reported by a user of Boost.MultiIndex β€”which library is BTW 13 years old :-)

https://stackoverflow.com/questions/47416304/boostmulti-index-container-crashes-with-com-ptr-t-objects

Basically, Boost.MultiIndex does not work with elements whose operator& is overloaded. The problem is scattered through the code, one of the locations being its dependency on boost/operators.hpp.

I understand changing this on your side requires that you update the documentation from

Requirements: (&*i). Return convertible to P.

to

Requirements: *i. Return convertible to R.

which is not, strictly speaking, a relaxation of the former condition β€”*i could in principle be anything as long as &*i returns a pointer. So it is up to you; if you decide to not do the change I can fix the issue on my side, although it's more verbose in terms of LOCs touched and the root problem might hit other code using boost/operators.hpp. FWIW commercial implementations of std containers guard themselves against abuses of operator& overloading via constructs similar to boost::addressof.

Thank you

from utility.

d-frey avatar d-frey commented on July 17, 2024

If Boost.MultiIndex is only 13 years old, you loose ;-P

Joking aside, I am not trying to ignore the problem, I was just curious where this was coming from. I think it is likely enough that people are not relying on the current implementation to allow them to "abuse" an overloaded operator&, so fixing it by using boost::addressof seems reasonable.

For the documentation part, well, it's not correct that the "return" is directly convertible to R. Maybe this would work:

Requirements: *i. Pointer to the return convertible to R.

or "...returned value..." instead of "...return..."?

from utility.

joaquintides avatar joaquintides commented on July 17, 2024

Requirements: *i. Pointer to the return convertible to R.

I think this not correct either... What about

Requirements: *i. The address of the returned value convertible to P.

"Address of a value" is a well-defined concept that does not depend on operator&, so I think this holds water.

from utility.

d-frey avatar d-frey commented on July 17, 2024

OK, agreed. I'll commit a fix soon.

from utility.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.