[LIB REQUEST]: add rjk::duck

Author: RyanJK5Created Sep 19, 2026Updated Sep 19, 2026
Labelsnew-libsrequest

Library name

rjk::duck

Library description

A C++26 library for zero-boilerplate generic type erasure.

Library repository

https://github.com/RyanJK5/rjk-duck

Motivation

Since it relies on new features that are not available to many people, it would be useful to place it in Compiler Explorer, which has significantly less barrier to access.

Here's a code example to test with:

cpp
#include <rjk/duck.hpp>

struct Fooable {
    int foo();
};

struct S {
    int foo() { return 5; }
};

int main() {
    rjk::duck<Fooable> d(S{});
    return d.foo();
}

Source: compiler-explorer/compiler-explorer