Skip to content

Instantly share code, notes, and snippets.

@dcci
Last active November 19, 2022 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcci/5175156ee2909dbd482295bc2f2493f6 to your computer and use it in GitHub Desktop.
Save dcci/5175156ee2909dbd482295bc2f2493f6 to your computer and use it in GitHub Desktop.
exponential inlining
# 3 "" 3
template < class a > struct b {
a c;
};
template < class > struct o;
template < class d > struct o< d * > {
typedef d e;
};
template < class f > class g {
public:
o< f >::e operator*();
void operator++();
};
template < class h > bool operator!=(g< h >, g< h >);
template < class i > struct j {
using k = i::l;
};
template < class i > struct m {
using n = i;
using l = j< n >::k;
using aa = int;
};
template < class > class ab;
template < class d, class = ab< d > > class p;
template < class d > class ab {
public:
typedef d *l;
};
template < class d, class af > class p {
public:
typedef m< af > w;
typedef g< typename w::l > q;
q begin() const;
q end() const;
d operator[](w::aa) const;
};
class r;
typedef long s;
typedef int ah;
typedef p< r > aj;
typedef p< b< r > > ak;
enum al { am };
int at_bb;
class r {
s an;
public:
r &ao(const r &);
template < typename ap > ap aq() const;
al ar() const;
template < typename as > auto at(as au) -> decltype(au(an));
template < typename as > auto av(as au) const -> decltype(au(an));
template < typename as > auto at(as au, const r &) -> decltype(au(an, s()));
operator ah() const;
};
struct aw;
struct ax {
aw &v;
p< r > u;
template < typename ap > auto operator()(ap t) -> decltype(v) { v(t, u); }
};
struct ay {
void operator()(double);
ah operator()(const aj &) const;
ah operator()(const ak &) const;
};
struct aw {
template < typename ap, typename az > void operator()(ap, az);
__attribute__((always_inline)) void operator()(ah, p< r > u) { ay()(u); }
};
r &r::ao(const r &ba) { at(aw(), ba); }
template < typename as >
__attribute__((always_inline, flatten)) auto r::at(as au) -> decltype(au(an)) {
au(at_bb);
}
template < typename as >
__attribute__((always_inline, flatten)) auto r::av(as au) const
-> decltype(au(an)) {
switch (ar())
case am: {
p< r > bc;
au(bc);
p< b< r > > bd;
au(bd);
}
}
template < typename as > auto r::at(as au, const r &) -> decltype(au(an, s())) {
at(ax{au});
}
template <> ah r::aq() const { av(ay()); }
__attribute__((always_inline, flatten)) r::operator ah() const { aq< ah >(); }
ah ay::operator()(const aj &be) const { (ah) be[0]; }
ah ay::operator()(const ak &be) const {
for (auto bf : be)
ah(bf.c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment