This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.

244. Must find's third argument be CopyConstructible?

Section: 27.6.6 [alg.find] Status: NAD Submitter: Andrew Koenig Opened: 2000-05-02 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [alg.find].

View all issues with NAD status.

Discussion:

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.

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.