Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Obj;
- class Wrapper {
- Obj* ptr;
- public:
- Wrapper(Obj* aptr) : ptr(aptr) {}
- Obj& operator*() {
- return *ptr;
- }
- operator const Obj*() {
- return ptr;
- }
- };
- class Obj {};
- void func(bool abool) {
- std::cout << "bool\n";
- }
- void func(Obj* obj) {
- std::cout << "obj\n";
- }
- int main() {
- // calls the obj variant
- func(new Obj());
- // calls the bool variant
- func(Wrapper(new Obj()));
- // calls the obj variant
- func(&*Wrapper(new Obj()));
- return 0;
- }
Add Comment
Please, Sign In to add comment