-
Notifications
You must be signed in to change notification settings - Fork 176
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
Oss 7 copy return for return by ref methods #310
Oss 7 copy return for return by ref methods #310
Conversation
…urn for return by ref or const ref function.
…com:iress/FakeIt into OSS-7-copy-return-for-return-by-ref-methods
Any change of getting this one in? Is there anything outstanding. |
For issue #258 |
Sorry for the late reply. In the original PR I made this comment: #280 (comment) The first two points aren't relevant anymore, but if you could answer the third one it would be nice. |
|
template<typename T> | ||
typename std::enable_if<!std::is_reference<T>::value && std::is_copy_constructible<T>::value, MethodStubbingProgress<R, arglist...>&>::type | ||
Return(T&& t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently I'm getting failures for this line/test: cannot convert argument 1 from 'int' to 'int &'
When(Method(mock, returnIntByRef)).Return(1);
template<typename T> | |
typename std::enable_if<!std::is_reference<T>::value && std::is_copy_constructible<T>::value, MethodStubbingProgress<R, arglist...>&>::type | |
Return(T&& t) { | |
template<typename U = R> | |
typename std::enable_if<!std::is_reference<T>::value && std::is_copy_constructible<T>::value, MethodStubbingProgress<R, arglist...>&>::type | |
Return(R&& r) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By "currently" you mean the code in the PR (so, without the changes in your message) or the code once you apply the changes in your message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, if I try this "suggested change" to the PR, then it fails for basic integer values (maybe because of other overloads)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this
typename std::enable_if<!std::is_reference<T>::value && std::is_copy_constructible<T>::value, MethodStubbingProgress<R, arglist...>&>::type
Return(R&& r) {
I get this error message:
referece_types_tests.cpp
c:\devel\git\fakeit\tests\referece_types_tests.cpp(196): error C2664: 'fakeit::MethodStubbingProgress &fakeit::MethodStubbingProgress::Return(void)': cannot convert argument 1 from 'int' to 'int &'
with
[
R=int &
]
Not saying there isn't a way to fix it but just haven't found it yet.
Also thinking the existing overload just shouldn't support R value refs at all, so should be specific to lvalue refs, in stead of all refs, as it will always be a dangling pointer, and hence always undefined behaviour.
Superseded by #332. |
New PR because I can't reopen the old one : #280