unary_function<...>::result cannot be void.
Jim King
jim_king_2000@163.com
Tue Apr 7 09:26:00 GMT 2009
Paolo Carlini-3 wrote:
>
> Jim King wrote:
>> Thank you very much for your reply. I tried it in OpenSolaris 11, no
>> problem.
>>
> It's a GCC bug with -g, only not a library issue. Can you file a normal
> Bugzilla PR? Otherwise, let me know and I will do it.
>> I'm so sorry that I disturb all of the users of the list. Never again. So
>> you can delete my thread.
>>
> That in general is impossible, for the record.
>> Last question, is there any authoritative place which I can ask
>> questions?
>>
> gcc-help? Or, if it's really about the C++ standard, comp.std.c++. In
> general, if you are unsure, filing the snippet in Bugzilla will provide
> you some sensible feedback.
>
> Paolo.
>
>
I'm a new guy to open source. I don't know what is Bugzilla PR... Sorry.
If you have interest, there is another question:
This code is failed to compile, either.
#include <functional>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
class test
{
public:
void func(int i) { wcout << i << L": test\n"; }
};
namespace
{
template<class T>
class destroyer : public unary_function<T, int>
{
private:
typedef unary_function<T, int> base_class;
private:
using typename base_class::result_type;
using typename base_class::argument_type;
public:
typename base_class::result_type operator()(argument_type pointer)
// compile error here
{
delete pointer; return 0;
}
};
}
int main()
{
vector<test *> data;
for (int i = 0; i < 5; ++i)
data.push_back(new test);
for_each(data.begin(), data.end(), bind2nd(mem_fun(&test::func), 0));
for_each(data.begin(), data.end(), destroyer<vector<test
*>::value_type>());
return 0;
}
The error line is:
typename base_class::result_type operator()(argument_type pointer) //
compile error here
The "argument_type" is denied by the compiler which means the using
directive does not work.
using typename base_class::result_type;
using typename base_class::argument_type;
Next time, I'll go to comp.std.c++.
Thank you again.
Jim
--
View this message in context: http://www.nabble.com/unary_function%3C...%3E%3A%3Aresult-cannot-be-void.-tp22922396p22925464.html
Sent from the gcc - libstdc++ mailing list archive at Nabble.com.
More information about the Libstdc++
mailing list