|
Boost : |
Subject: [boost] [parameter] compiler errors with operator()
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2010-05-10 16:47:08
Hello all,
I am trying to compile the example from Boost.Parameter section 2.2
but I get the GCC errors below. The errors go aways if I name the
member function `f` instead of `operator()`.
What am I doing wrong? How do I use Boost.Parameter with member operators?
// File: "c2.cpp".
#include <boost/parameter.hpp>
#include <iostream>
BOOST_PARAMETER_NAME(arg1)
BOOST_PARAMETER_NAME(arg2)
struct callable2
{
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
(void), operator(), tag, (required (arg1,(int))(arg2,(int))))
{
std::cout << arg1 << ", " << arg2 << std::endl;
}
};
int main() {
callable2 c2;
c2(1, 2);
c2(2, 1);
return 0;
}
$ g++ -Wall -Werror example/Own/parameter/c2.cpp
example/Own/parameter/c2.cpp:10: error: expected unqualified-id before ) token
example/Own/parameter/c2.cpp:10: error: expected unqualified-id before ) token
example/Own/parameter/c2.cpp:10: error: expected unqualified-id before ) token
example/Own/parameter/c2.cpp:10: error: expected nested-name-specifier
before boost_param_result_11operator
example/Own/parameter/c2.cpp:10: error: expected initializer before < token
example/Own/parameter/c2.cpp:10: error: expected nested-name-specifier
before boost_param_result_11operator
example/Own/parameter/c2.cpp:10: error: expected initializer before < token
example/Own/parameter/c2.cpp:10: error:
boost_param_default_11operator declared as function returning a
function
example/Own/parameter/c2.cpp: In member function int
callable2::boost_param_default_11operator():
example/Own/parameter/c2.cpp:13: error: arg1 was not declared in this scope
example/Own/parameter/c2.cpp:13: error: arg2 was not declared in this scope
cc1plus: warnings being treated as errors
example/Own/parameter/c2.cpp:14: warning: no return statement in
function returning non-void
example/Own/parameter/c2.cpp: In function int main():
example/Own/parameter/c2.cpp:19: error: no match for call to
(callable2) (int, int)
example/Own/parameter/c2.cpp:20: error: no match for call to
(callable2) (int, int)
$ g++ --version
g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
I am using Boost v1.42.0
Thank you very much.
-- Lorenzo P.S. Shall I report these type of questions on this mailing list or in Boost's TRAC? I am new to Boost.Parameter so I am not sure these are actual bugs...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk