Opened 13 years ago

Closed 13 years ago

#3168 closed Feature Requests (fixed)

Request for boost::array::fill(const T&), following C++0x

Reported by: niels_dekker Owned by: Marshall Clow
Milestone: Boost 1.40.0 Component: array
Version: Boost 1.39.0 Severity: Problem
Keywords: Cc: niels_dekker

Description

According to the latest C++0x Working Draft, N2857, std::array will have a member function named fill.

Quoting 23.3.1.5 array::fill [array.fill]:

requires CopyAssignable<T> void fill(const T& u);
1 Effects: fill_n(begin(), N, u)

Even while using a compiler that does not support C++0x concepts, I think it's desirable to have this function added to boost::array already. E.g., as follows:

        void fill(const T& value)
        {
            std::fill_n(elems, N, value);
        }

Of course, it is effectively the same as boost::array::assign. Maybe boost::array::assign should become deprecated.

Change History (6)

comment:1 by niels_dekker, 13 years ago

Related LWG issue (defect): 776. Undescribed assign function of std::array, submitted by Daniel Krügler

comment:2 by Steven Watanabe, 13 years ago

Owner: changed from No-Maintainer to Steven Watanabe
Status: newassigned

comment:3 by niels_dekker, 13 years ago

Thanks for assigning the ticket, Steven. Clearly, the intention of the ticket is to keep boost::array in sync with std::array from C++0x. Only after submitting the ticket, I realized that none of the other STL containers has a fill member function. And it isn't really clear to me why std::array has one. (I might as well use the range-based fill algorithm instead.) What do you think?

in reply to:  3 comment:4 by Steven Watanabe, 13 years ago

Replying to niels_dekker:

Thanks for assigning the ticket, Steven. Clearly, the intention of the ticket is to keep boost::array in sync with std::array from C++0x. Only after submitting the ticket, I realized that none of the other STL containers has a fill member function. And it isn't really clear to me why std::array has one. (I might as well use the range-based fill algorithm instead.) What do you think?

On the other hand, the other standard containers have a

void assign(size_type n, const T& u);

fill is the equivalent for array since the size of an array is fixed.

comment:5 by Marshall Clow, 13 years ago

Owner: changed from Steven Watanabe to Marshall Clow
Status: assignednew

Added in revision 60436. Will migrate to release before 1.43

comment:6 by Marshall Clow, 13 years ago

Resolution: fixed
Status: newclosed

Migrated to release branch in revision 60824

Note: See TracTickets for help on using tickets.