template<class s>constexpr size_t strlen(const s& text) noexcept;
#include <iostream>#include <cassert>template<class s> constexpr size_t strlen(const s& text) noexcept{ assert(text); const auto* cur = text; while(*cur != 0) ++cur; return static_cast<size_t>(cur - text);}int main(){ enum { len = strlen("1234") }; std::cout << "len = " << len << '\n';}
source_file.cpp(16): error C2131: expression did not evaluate to a constantsource_file.cpp(16): note: failure was caused by call of undefined function or one not declared 'constexpr'source_file.cpp(16): note: see usage of 'strlen'Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64
C++ (Qt)class X{ void method () &; void method () const &; void method () volatile &; void method () const volatile &; void method () &&; void method () const &&; void method () volatile &&; void method () const volatile &&;};
C++ (Qt)class X{ void method () mutable, const &, volatile &&, const volatile; // как-нибудь так // или по-другому};
C++ (Qt) #define METHOD_PROTOTYPE( refer ) ... #define METHOD \ METHOD_PROTOTYPE( && ) \ METHOD_PROTOTYPE( const && ) \ METHOD_PROTOTYPE( volatile && ) \ METHOD_PROTOTYPE( const volatile && ) \ METHOD_PROTOTYPE( & ) \ METHOD_PROTOTYPE( const & ) \ METHOD_PROTOTYPE( volatile & ) \ METHOD_PROTOTYPE( const volatile & ) \ class X{ METHOD};
C++ (Qt)template<class T>T Lerp( const T & a, const T & b, double w );