String-interning at compiletime for profiling

Identical literal strings are not guaranty to be identical, but you can build type from it which can compare identical (without comparing string), something like: // Sequence of char template <char…Cs> struct char_sequence { template <char C> using push_back = char_sequence<Cs…, C>; }; // Remove all chars from char_sequence from ‘\0’ template <typename, char…> struct … Read more

Scala3: Crafting Types Through Metaprogramming?

Just in case, here is what I meant by hiding ViewOf inside a type class (type classes is an alternative to match types). Sadly, in Scala 3 this is wordy. (version 1) import scala.annotation.experimental import scala.quoted.{Expr, Quotes, Type, quotes} // Library part trait View extends Selectable { def applyDynamic(key: String)(args: Any*): Any = { println(s”$key … Read more

Why is partial specialization of a nested class template allowed, while complete isn’t?

My guess as to why this happens: complete specializations are no longer “template classes/functions”, they are are “real” classes/methods, and get to have real (linker-visible) symbols. But for a completely-specialized template inside a partially-specialized one, this would not be true. Probably this decision was taken just to simplify the life of compiler-writers (and make life … Read more

Can I use Roslyn for compile time code rewriting?

Compile time re-writing isn’t directly supported by Roslyn today, but syntactic and semantic transformations definitely are. In fact, take a look at the “ImplementNotifyPropertyChanged” sample included in the CTP to see something of what you want to do. The sample is implemented as a design time transformation in and IDE feature, but you can extract … Read more