Matt Calabrese: Boost.Generic: Concepts without Concepts
Why Stack Overflow recommends it
Stack Overflow users link it as the primary source when they need Matt Calabrese's advanced C++ metaprogramming tricks, such as stateful compile-time registration and constrained function templates.
Recommended by 0 people across 0 different months, 2017 to 2022.
What it is
A CppNow 2013 conference talk by Matt Calabrese introducing Boost.Generic, a C++11 library for defining concepts, concept maps and concept-based function template overloads without language support. It covers compile-time assertions, concept checking and overload constraints, and shows advanced template techniques such as stateful metaprogramming.
What people said
Cites Paul Fultz II · 2017-02 · Stack Overflow · on “C++14 Metaprogramming: Automagically build a list of types at compile / init time”
To do it at compile-time will require "stateful" metaprogramming. In this article here [LINK] , Filip Roséen explains how to implement the following using extremely advanced C++14: LX::push<void, void, void, void> (); LX::set<0, class Hello> (); LX::set<2, class World> (); LX::pop (); LX::value<> x; // type_list<class Hello, void, class World> Also, Matt Calabrese used similar techniques to implements semantic-based concepts in C++11, see the video [this video] and slides [LINK] at slide #28. Of course, these techniques rely on a compiler supporting conformant two-phase name lookup. Alternatively, you can restucture your code to support runtime registration instead, which is much simpler, and can
Cites Chris Beck · 2017-09 · Stack Overflow · on “Create an alias from one type to another”
The problem is that I've not been able to find the way to alias Interface and Impl in compile time so far. I can do this using RTTI but I really don't want to use it. Is it possible at all? There is a trick you can use to do this, assuming I understood your goal correctly. It won't look as nice as what you have there: [LINK] This trick was attributed to Matt Calabrese, he described it in a Boostcon talk in like 2011 [this video] . To the best of my knowledge this trick is standards-conforming, but you must be very careful -- if you do start the registration in some header files and then continue it in some CPP files you may cause an ODR violation if you are careless. I think you would end up with
Cites Brian Bi · 2022-03 · Stack Overflow · on “How to implement Matt Calabrese's BOOST_AUTO_FUNCTION idea?”
In a talk from BoostCon 2011 [this video] , Matt Calabrese gives the following hypothetical syntax: template< class L, class R > BOOST_AUTO_FUNCTION( operator -( L const& lhs, R const& rhs ) , if ( is_vector_udt< L > ) ( is_vector_udt< R > ) , try ( lhs + rhs ) ( -rhs ) , if typename ( L::value_type ) ) ( return lhs + -rhs ) The idea is that this declares a function template: named operator- , with arguments L const& lhs and R const& rhs , which does not participate in overload resolution unless is_vector_udt<L> and is_vector_udt<R> are true, which does not participate in overload resolution unless lhs + rhs and -rhs are valid expressions, which does not participate in overload resolution unless