GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • cpprefjp - C++日本語リファレンス
  • GitHub Project

This view

  • Original page
  • New address

GeezerVison is showing cpprefjp.github.io — std::permutable - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. iterator
  3. permutable

最終更新日時: 2026年09月19日 21時31分51秒 (JST)
rotarymars が更新

履歴 編集

concept
<iterator>

std::permutable(C++20)

namespace std {
  template<class I>
  concept permutable =
    forward_iterator<I> &&
    indirectly_movable_storable<I, I> &&
    indirectly_swappable<I, I>;
}

概要

permutableは、イテレータ型Iについてその要素のmove/swapによって要素の位置を並べ替えることができる事を表すコンセプトである。

例

#include <iostream>
#include <concepts>
#include <iterator>
#include <memory>
#include <vector>
#include <forward_list>
#include <list>

template<std::permutable I>
void f(const char* name) {
  std::cout << name << " is permutable" << std::endl;
}

template<typename I>
void f(const char* name) {
  std::cout << name << " is not permutable" << std::endl;
}

int main() {
  f<int*>("int*");
  f<std::forward_list<int>::iterator>("std::forward_list<int>::iterator");
  f<std::list<int>::iterator>("std::list<int>::iterator");
  f<std::vector<int>::iterator>("std::vector<int>::iterator");
  f<std::vector<std::unique_ptr<int>>::iterator>("std::vector<std::unique_ptr<int>>::iterator");

  std::cout << "\n";
  f<const int*>("const int*");
  f<int* const>("int* const");
  f<std::istream_iterator<double>>("std::istream_iterator<double>");
  f<std::ostream_iterator<double>>("std::ostream_iterator<double>");
}

出力

int* is permutable
std::forward_list<int>::iterator is permutable
std::list<int>::iterator is permutable
std::vector<int>::iterator is permutable
std::vector<std::unique_ptr<int>>::iterator is permutable

const int* is not permutable
int* const is not permutable
std::istream_iterator<double> is not permutable
std::ostream_iterator<double> is not permutable

バージョン

言語

  • C++20

処理系

  • Clang: 15.0.7 ✅
  • GCC: 10.1 ✅
  • Visual C++: 2019 Update 6 ✅

関連項目

  • C++20 コンセプト

参照

  • P0896R4 The One Ranges Proposal (was Merging the Ranges TS)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.