Left Arrow Operator

Kent - January 13, 2024

Usually the right arrow operator -> will point to some method or value of a pointer. There is also a left arrow operator <-, it is used when you have a pointer to a method and it should be invoked on a class.


Use this if you are brave.

#include <iostream>
template<class T>
struct larrow {
    larrow(T* a_) : a(a_) { }
    T* a;
template <class T, class R>
R operator<(R (T::* f)(), larrow<T> it) {
    return (it.a->*f)();
template<class T>
larrow<T> operator-(T& a) {
    return larrow<T>(&a);
struct C {
    void f() { std::cout << "foo\n"; }    
int main() {
    C x;

See Also


Any comments? Create a new discussion on GitHub.
There used to be an inline comment form here, but it was removed.