/* * WiVRn VR streaming * Copyright (C) 2025 Guillaume Meunier * Copyright (C) 2025 Patrick Nicolas * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include namespace details { template struct method_trait {}; template struct method_trait { static Result magic(Class::base * arg, Args... args) { return std::invoke(Method, static_cast(arg), args...); } }; } // namespace details namespace wivrn { // Convert a pointer to member function to a free function that takes the object as first argument. // The class needs to have a "base" type which will be used for the first argument. // // Example: // class derived: public base_class // { // using base = base_class; // void foo(int x); // }; // // method_pointer<&derived::foo> is equivalent to // void free_foo(base_class * base, int x) { // return static_cast(base)->foo(x); // } template auto method_pointer = ::details::method_trait::magic; } // namespace wivrn