Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classic: Fixed position_iterator forming reference to local #422

Conversation

Projects
None yet
2 participants
@Kojoley
Copy link
Collaborator

commented Nov 23, 2018

When underlying iterator returns by value the corresponding position_iterator was providing iterator_adaptor with a reference type what lead to returning a reference to a local variable in dereference operator.

Made a custom trait because it is a way more elegant than:

    typedef typename boost::mpl::if_c<
        boost::is_reference<reference>::value,
        typename boost::add_reference<
            typename boost::add_const<
                typename boost::remove_reference<reference>::type
            >::type
        >::type,
        typename boost::add_const<reference>::type
    >::type const_reference_type;

Fixes https://svn.boost.org/trac10/ticket/9737.

Classic: Fixed position_iterator forming reference to local
When underlying iterator returns by value the corresponding position_iterator
was providing iterator_adaptor with a reference type what lead to returning
a reference to a local variable in dereference operator.

Made a custom trait because it is a way more elegant than:
```cpp
    typedef typename boost::mpl::if_c<
        boost::is_reference<reference>::value,
        typename boost::add_reference<
            typename boost::add_const<
                typename boost::remove_reference<reference>::type
            >::type
        >::type,
        typename boost::add_const<reference>::type
    >::type const_reference_type;
```

Fixes https://svn.boost.org/trac10/ticket/9737.
@djowel

This comment has been minimized.

Copy link
Member

commented Nov 23, 2018

wonderful!

@Kojoley Kojoley merged commit 0bfc421 into boostorg:develop Nov 23, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Kojoley Kojoley deleted the Kojoley:classic-fix-position_iterator-returns-reference-to-local branch Nov 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.