Modernes C++ programmieren

Okt 23, 2024

lst-0648-book.cpp

// https://godbolt.org/z/Tcxnr6jTM 
template<typename T>
  concept dbl_quotable = copyable<T> &&
  requires (T t) { mk_string(t) + mk_string(t); } &&
  requires(T t) {
    {mk_string(t)} -> same_as<string>;
  };
string dbl_quote(const dbl_quotable auto& val) {
  auto val2{val}; // Kopie erzeugen (nur zu Demozwecken)
  return '"' + mk_string(val) + mk_string(val2) + '"';
}