Title
Must find's third argument be CopyConstructible?
Status
nad
Section
[alg.find]
Submitter
Andrew Koenig

Created on 2000-05-02.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

There is no indication in the standard that find's third argument is required to be Copy Constructible. The LWG believes that no such requirement was intended. As noted above, there are times when a user might reasonably pass an argument that is not Copy Constructible.

Date: 2000-05-02.00:00:00

Is the following implementation of find acceptable?

        template<class Iter, class X>
        Iter find(Iter begin, Iter end, const X& x)
        {
            X x1 = x;           // this is the crucial statement
            while (begin != end && *begin != x1)
                ++begin;
            return begin;
        }

If the answer is yes, then it is implementation-dependent as to whether the following fragment is well formed:

        vector<string> v;

        find(v.begin(), v.end(), "foo");

At issue is whether there is a requirement that the third argument of find be CopyConstructible. There may be no problem here, but analysis is necessary.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg1987
2000-05-02 00:00:00admincreate