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

### 284. unportable example in 20.3.7, p6

Section: 22.10.8 [comparisons] Status: CD1 Submitter: Martin Sebor Opened: 2000-12-26 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [comparisons].

View all other issues in [comparisons].

View all issues with CD1 status.

Discussion:

The example in 22.10.8 [comparisons], p6 shows how to use the C library function `strcmp()` with the function pointer adapter `ptr_fun()`. But since it's unspecified whether the C library functions have `extern "C"` or `extern "C++"` linkage [16.4.3.3 [using.linkage]], and since function pointers with different the language linkage specifications (9.11 [dcl.link]) are incompatible, whether this example is well-formed is unspecified.

Proposed resolution:

Change 22.10.8 [comparisons] paragraph 6 from:

> [Example:

>         replace_if(v.begin(), v.end(), not1(bind2nd(ptr_fun(strcmp), "C")), "C++");

> replaces each `C` with `C++` in sequence `v`.

to:

> [Example:

>         int compare(const char*, const char*);
>         replace_if(v.begin(), v.end(),
>                    not1(bind2nd(ptr_fun(compare), "abc")), "def");

> replaces each `abc` with `def` in sequence `v`.

Also, remove footnote 215 in that same paragraph.

[Copenhagen: Minor change in the proposed resolution. Since this issue deals in part with C and C++ linkage, it was believed to be too confusing for the strings in the example to be "C" and "C++". ]

[Redmond: More minor changes. Got rid of the footnote (which seems to make a sweeping normative requirement, even though footnotes aren't normative), and changed the sentence after the footnote so that it corresponds to the new code fragment.]