Opened 7 years ago

Last modified 7 years ago

#12068 new Feature Requests

boost::filtered_range is not default constructible

Reported by: Aleksej Lebedev <root@…> Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost 1.59.0 Severity: Problem
Keywords: filtered_range, adaptors Cc:

Description

Filtered_range is not default_constructible which makes it impossible to (for example) put it into a class that has to be default-initialized and resets it (filtered_range) later.

I'm quite new to boost internals, but I fail to see any drawbacks of adding the default constructor:

--- include/boost/range/adaptor/filtered.hpp.orig 2016-03-14 15:26:32.228892237 +0100 +++ include/boost/range/adaptor/filtered.hpp 2016-03-14 15:26:28.724846102 +0100 @@ -41,6 +41,8 @@

typedef typename default_constructible_unary_fn_gen<P, bool>::type

pred_t;

+ filtered_range() {} +

filtered_range(P p, R& r) : base(make_filter_iterator(pred_t(p),

boost::begin(r), boost::end(r)),

Change History (3)

comment:1 by Michel Morin, 7 years ago

Component: Nonerange
Owner: set to Neil Groves
Type: BugsFeature Requests

comment:2 by Michel Morin, 7 years ago

For reference, range views in Eric Niebler's Range v3 have default constructors.

P.S. If you want to workaround, you can use boost::optional's deferred initialization.

in reply to:  2 comment:3 by Aleksej Lebedev <root@…>, 7 years ago

Replying to michel:

P.S. If you want to workaround, you can use boost::optional's deferred initialization.

Actually, we just applied the patch. But thanks for the suggestion anyway.

Note: See TracTickets for help on using tickets.