Help us understand the problem. What is going on with this article?


More than 1 year has passed since last update.


// Go2
contract stringer(x T) {
  var s string = x.String()

func Stringify(type T stringer)(s []T) (ret []string) {
  for _, v := range s {
    ret = append(ret, v.String())
  return ret
// C++20
#include <string>
#include <span>
#include <vector>
using namespace std;

template <typename T>
concept Stringer = requires (T x) {
  { x.to_string() } -> string;

template <Stringer E>
auto stringify(span<E> s) -> vector<string>
  vector<string> ret;
  for (auto&& v: s) {
  return ret;




Go2ジェネリクス仕様は Contracts - Draft Design, Aug/27/2018 を参考にしました。
C++20コンセプト仕様は N4800 Working Draft 仕様に基づきます。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away