Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function call by reference not supported? #83

Open
shierei opened this issue Jun 21, 2017 · 2 comments
Open

function call by reference not supported? #83

shierei opened this issue Jun 21, 2017 · 2 comments
Assignees
Labels

Comments

@shierei
Copy link
Contributor

shierei commented Jun 21, 2017

It looks like if you create a member function with a reference type, it fails to compile when you declare this class member function to Ponder. For example, suppose I add a member function as follows in the Ponder example with the person class.

void callByRef(int& a)
{
    a = 10;
}

The declaration below would not compile.

.function("callByRef", &Person::callByRef)

/opt/rh/devtoolset-3/root/usr/include/c++/4.9.1/functional:2434:5:
    note: _Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {Person&, int&}]
 function<_Res(_ArgTypes...)>::
 ^
/opt/rh/devtoolset-3/root/usr/include/c++/4.9.1/functional:2434:5:
    note:   no known conversion for argument 2 from ?ponder::runtime::impl::ConvertArg<2, int&>::ReturnType {aka int}? to ?int&?

Is this documented? Why can it be supported?

-Shie-rei

@shierei
Copy link
Contributor Author

shierei commented Aug 10, 2017

I tried this out on CAMP. CAMP compiled fine but in run time, instead of doing call by reference, it behaves as call by value.

@billyquith
Copy link
Owner

I'll try and find some time to look at it. In the meantime I can only suggest looking at the unit tests, which are fairly extensive, and source code.

I vaguely remember something about CAMP stripping the qualifiers from argument types. Part of the problem is that it has a generic calling mechanism and possibly types get coerced/simplified so the thing you think you are referencing is not what you think it is.

@billyquith billyquith self-assigned this May 1, 2018
@billyquith billyquith added this to the 3.0 - Big refactor milestone May 21, 2018
billyquith added a commit that referenced this issue Nov 12, 2020
- Experiment to see what current happens. Commented out as unsupported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants