[RFC/partial patch] libstdc++/11400
Paolo Carlini
pcarlini@unitus.it
Wed Jul 2 21:30:00 GMT 2003
Hi,
this is the testcase:
//////
#include <algorithm>
struct Integral { operator int() const; };
namespace std {
template int* search_n (int*, int*, Integral, const int&);
}
//////
which currently doesn't compile
/build/contrib/gcc-3.2/include/c++/3.2/bits/stl_algo.h: In function
`_ForwardIter std::search_n(_ForwardIter, _ForwardIter, _Integer, const
_Tp&) [with _ForwardIter = int*, _Integer = Integral, _Tp = int]':
t.cpp:7: instantiated from here
/build/contrib/gcc-3.2/include/c++/3.2/bits/stl_algo.h:612: conversion from `
int' to non-scalar type `Integral' requested
/build/contrib/gcc-3.2/include/c++/3.2/bits/stl_algo.h:617: no match for `--
Integral&' operator
what I'm proposing is dispatching basing on the _Is_integer trait to a general
safe version using distance() and a special version same as the current one.
I'm attaching below a *preliminary* patch for the first of the two versions
of search_n, the simplest, that without the BinaryPredicate.
Seems a reasonable approach? In case I would complete it with the second case,
prepare a set of testcases, missing for search_n, and so on...
Paolo.
//////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_11400
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20030702/ae99f6e3/attachment.ksh>
More information about the Libstdc++
mailing list