cd /news/developer-tools/as Β· home β€Ί topics β€Ί developer-tools β€Ί article
[ARTICLE Β· art-10236] src=gist.github.com β†— pub= topic=developer-tools verified=true sentiment=Β· neutral

as

Based on the provided text, the article appears to be a C++ code snippet that defines a custom type `as` and an overloaded `operator->*`. This code enables a syntax for type casting, allowing expressions like `value ->* as<T>()` to perform a static cast to type `T`, using a combination of a struct, a macro, and operator overloading.

read1 min views22 publishedMay 6, 2026

Last active May 22, 2026 23:01

Save Eczbek/9ef572fbfc3ae00bd6ee11f1b6ab7007 to your computer and use it in GitHub Desktop.

as

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.

Learn more about bidirectional Unicode characters| #include<concepts> | | | #include<utility> | | | struct as{template<class T>operator T(){std::unreachable();};template<class T>struct x{T&&x;template<class U>[[nodiscard]]constexpr decltype(static_cast<U>((T&&)x))operator->(U(as::)())noexcept(noexcept(static_cast<U>((T&&)x))){return static_cast<U>((T&&)x);}};};constexpr auto operator->(auto&&x,std::same_as<as>auto)noexcept{return as::x<decltype(x)>((decltype(x))x);} | | | #define as ->::as()->*&::as::operator |

Author

Unlike static_cast

, this does not extend the lifetime of a temporary object bound to a reference:

{
    const int& x = static_cast<const int&>(0);
}
// The object is destroyed when the reference goes out of scope

{
    const int& x = 0 as const int&;
    // The object is destroyed at the end of the full-expression
}
── more in #developer-tools 4 stories Β· sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/as] indexed:0 read:1min 2026-05-06 Β· β€”