Comments (8)
I see that MSVC also complains for the same reason. This is tricky. I'll see what I can do.
from trompeloeil.
@rollbear: I have seen the conversion warning from GCC before, as reported here: https://godbolt.org/z/zrsdvrhKf .
I'll check my working notes from a couple of years ago and see if the strategy applied then can be reused (sadly I seem to recall it required a rewrite of client code). I also have a new idea to try in the next day or so, and will report success or failure following the experiment.
from trompeloeil.
I tried to simplify the problem and I got nothing, but some curiosities:
- Removing both const qualifier makes GCC also fail:
- from the Variant constructor parameter
- from the Wildcard conversion operator
- clang also fails Variant variant = wildcard;
- MSVC, however, compiles it.
struct Variant
{
template <typename T>
Variant(const T&)
{}
};
struct Wildcard
{
template<typename T>
operator T()
const
{
return *this;
}
};
void func(Variant) { };
int main()
{
Wildcard wildcard{};
Variant variant = wildcard;
func(wildcard);
return 0;
}
https://godbolt.org/z/bfh5Mj61h
from trompeloeil.
I can make your example work, but at the cost of reintroducing other old bugs instead. Hopefully I'll find something, but it may take a while.
from trompeloeil.
Some progress, but not yet there.
This works, but it gives a conversion warning with gcc, which I am not OK with.
https://godbolt.org/z/zrsdvrhKf
So far no success in getting rid of that warning without breaking things even more.
from trompeloeil.
Thank you very much! I integrated your fix explicitly for clang using "#ifdef clang" and left the original for gcc. I hope you find a better solution that makes you happy :).
from trompeloeil.
I was hoping ref-qualification (&
and &&
) of the conversion operators was going to restrict their application, but it created more issues (interesting issues!) and solved no issues. Perhaps they are exactly the reverse of what's needed. Still investigating.
from trompeloeil.
I have failed to find a better solution, so going with this and suppressing the -Wconversion warning on gcc. Not entirely happy about this. Leaving the issue open until a release has been tagged.
from trompeloeil.
Related Issues (20)
- How can i mock a member function of A class in a B class's function? HOT 3
- CMake version required not correct HOT 5
- Setting expectations in a function fails HOT 6
- how can I mock the static member function and non-virtual member fuctions? HOT 2
- Problematic traits for ``streamer`` primary template HOT 4
- Documentation, typo and missing bits and bobs HOT 3
- Compile error when returning values from a tl::expected with a void expected value HOT 5
- Refactoring with sequenced expectations HOT 2
- Build for QNX tests fail due to catch2 header file HOT 1
- Wrong Expectaition message HOT 1
- [Bug] Fails to run tests with catch 3.x HOT 4
- Tests fail to compile: error: 'ret_count' is an unsafe buffer that does not perform bounds checks HOT 4
- Expect call returning a reference HOT 2
- can this cppcheck inline suppression be added HOT 1
- unreal engine support & noreturn/std::abort HOT 3
- Setting side effects after creating expectactions (inside DOCTEST_SUBCASEs) HOT 5
- Feature Request: Allow specifying calling convention attributes to Mock methods HOT 12
- Spy some dependencies HOT 3
- ``trompeloeil_movable_mock`` only provides move-ctor HOT 3
- Warnings with gcc's -Weffc++ HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trompeloeil.