functor parameter problem
hi i have a problem.
Quote:
error: no matching function for call to `test1(int&, int)'
Code:
namespace test0 {
template<typename test10, typename test11>
const bool test1(bool&, const test10&, const test11&)
{
return(true);
}
}
template<typename test10, typename test11, typename test12>
const bool test1(test10&, const test11&, const test12& = test0::test1)
{
return(false);
}
int main(void)
{
int x = 0;
test1(x, 0);
}
i dont know why functor wrong.
Re: functor parameter problem
do anyonje know its kind of urgent
Re: functor parameter problem
Your test1 template takes three concrete (non-default) arguments. You are instantiating the template using only two arguments.
Code:
template<typename test10, typename test11, typename test12>
bool test1(test10&, const test11&, const test12& = test0::test1)
{
}
int main(void)
{
int x = 0;
test1(x, 0, true); // this works
}
This compiles fine with Comeau.
Regards,
Re: functor parameter problem
What is the third parameter intended to be used for?
Re: functor parameter problem
Yep, template argument deduction on the second test1 overload can't be complete as test12 can't be deduced.
Re: functor parameter problem
i would rather hear a solution.
i have tried this:
Code:
struct
{
template<typename test10, typename test11>
const bool operator()(bool& x, const test10& y , const test11& z) const
{
return(x = true);
}
} test1;
template<typename test10, typename test11, typename test12>
const bool test2(test10& x, const test11& y, const test12& z = test1)
{
bool a;
z(a, x, y);
return(a);
}
int main(void)
{
int x = 0;
test2(x, 0, test1);
}
it should be able to deduce test12 now but still no match.
Re: functor parameter problem
Quote:
Originally Posted by Mitsukai
i would rather hear a solution.
So what do you call what I posted using your original code? There were no compilation errors in the example I posted if you specify the last parameter when the template is instantiated.
Now you've changed the code to a totally different example that doesn't compile for an entirely different set of reasons:
Quote:
Thank you for testing your code with Comeau C/C++!
Tell others about
http://www.comeaucomputing.com/tryitout !
Your Comeau C/C++ test results are as follows:
Comeau C/C++ 4.3.8 (Aug 19 2006 13:36:48) for ONLINE_EVALUATION_Alpha1
Copyright 1988-2006 Comeau Computing. All rights reserved.
MODE:strict errors C++
"ComeauTest.c", line 4: warning: type qualifier on return type is meaningless
const bool operator()(bool& x, const test10& y , const test11& z) const
^
"ComeauTest.c", line 8: error: use of a type with no linkage to declare a variable
with linkage
} test1;
^
"ComeauTest.c", line 11: warning: type qualifier on return type is meaningless
const bool test2(test10& x, const test11& y, const test12& z = test1)
^
"ComeauTest.c", line 21: error: a template argument may not reference an unnamed
type
test2(x, 0, test1);
^
2 errors detected in the compilation of "ComeauTest.c".
In strict mode, with -tused, Compile failed
Code:
struct test1
{
template<typename test10, typename test11>
bool operator()(bool& x, const test10& y , const test11& z) const
{
return(x = true);
}
};
test1 test_inst;
template<typename test10, typename test11, typename test12>
bool test2(test10& x, const test11& y, const test12& z = test_inst)
{
bool a;
z(a, x, y);
return(a);
}
int main(void)
{
int x = 0;
test2(x, 0, test_inst);
}
This compiles fine.
Regards,
Paul McKenzie
Re: functor parameter problem
but this does not .
Code:
struct test1t
{
template<typename test10, typename test11>
const bool operator()(bool& x, const test10& y , const test11& z) const
{
return(x = true);
}
};
test1t test1;
template<typename test10, typename test11, typename test12>
const bool test2(test10& x, const test11& y, const test12& z = test1)
{
bool a;
z(a, x, y);
return(a);
}
int main(void)
{
int x = 0;
test2(x, 0);
}
Re: functor parameter problem
It doesn't compile for the same reasons as the first example.
Regards,
Paul McKenzie