GeezerVison is showing cpprefjp.github.io — std::common_type - cpprefjp C++日本語リファレンス
最終更新日時:
2026年08月18日 11時14分29秒 (JST)
Akira Takahashi
が更新
履歴
編集
class template
<iterator>
std:: common_type (C++23)
namespace std {
// (1)
template < class T , common_with < T > U >
requires input_iterator < common_type_t < T , U >>
struct common_type < basic_const_iterator < T > , U > {
using type = basic_const_iterator < common_type_t < T , U >> ;
};
// (2)
template < class T , common_with < T > U >
requires input_iterator < common_type_t < T , U >>
struct common_type < U , basic_const_iterator < T >> {
using type = basic_const_iterator < common_type_t < T , U >> ;
};
// (3)
template < class T , common_with < T > U >
requires input_iterator < common_type_t < T , U >>
struct common_type < basic_const_iterator < T > , basic_const_iterator < U >> {
using type = basic_const_iterator < common_type_t < T , U >> ;
};
}
概要
basic_const_iteratorのためのcommon_type 特殊化。
(1), (2) : basic_const_iteratorとその他のイテレータ型の間の共通の型を取得する
(3) : 異なるイテレータ型によるbasic_const_iterator特殊化の間の共通の型を取得する
例
#include <iterator>
int main () {
using ct1 = std::common_type_t < int * , std :: const_iterator < int *>> ;
static_assert ( std :: same_as < ct1 , std :: basic_const_iterator < int *>> );
using ct2 = std::common_type_t < std :: const_iterator < int *> , int *> ;
static_assert ( std :: same_as < ct1 , ct2 > );
using ct3 = std::common_type_t < const int * , std :: const_iterator < int *>> ;
static_assert ( std :: same_as < ct3 , std :: basic_const_iterator < const int *>> );
using ct4 = std::common_type_t < std :: basic_const_iterator < int *> , std :: basic_const_iterator < const int *>> ;
static_assert ( std :: same_as < ct4 , std :: basic_const_iterator < const int *>> );
}
出力
バージョン
言語
処理系
関連項目
参照