Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#6212 closed Bugs (fixed)

"Method 3.1: Implement a Range Adaptor without arguments" does not implement

Reported by: ne01026@… Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

The sample code in Method 3.1: Implement a Range Adaptor without arguments is incomplete; it does not provide for the syntax range | ::boost:: adaptors:: reversed.

Change History (5)

comment:1 by ne01026@…, 11 years ago

It turns out that the following code is needed to finish up:

namespace
        {
            const detail::reverse_forwarder reversed = 
                                            detail::reverse_forwarder();
        }

I wonder why the explicit assignment is needed? Or should it be a reference instead?

in reply to:  1 comment:2 by Nathan Ridge, 10 years ago

Replying to ne01026@…:

I wonder why the explicit assignment is needed? Or should it be a reference instead?

It should not be a reference (it would be a reference to a temporary which will have died long before one tries to use it).

Regarding why the explicit assignment is needed, see http://stackoverflow.com/questions/8092670/uninitialized-const. I believe

    const detail::reverse_forwarder reversed = {};

also does the trick.

comment:3 by Nathan Ridge, 10 years ago

Resolution: fixed
Status: newclosed

(In [82314]) [range] fixed #6212 (missing step in documentation for how to write a range adaptor)

comment:4 by Nathan Ridge, 10 years ago

Fixed in trunk. The fix will appear in 1.53 (I will merge to release branch after 1.53 beta release).

Thanks for the report!

comment:5 by Nathan Ridge, 10 years ago

(In [82487]) [range] Merge documentation fixes and minor refactoring of docs (refs #5160; refs #5314; refs #5440; refs #5775; refs #6212; refs #7585; refs #7843; refs #7866).

Note: See TracTickets for help on using tickets.