tools
読み取り中…
検索中…
一致する文字列を見つけられません
type.h
[詳解]
1
// boostヘッダを使うので、debug.hとは分けておきたい
2
#pragma once
3
#include <string>
4
#include <boost/type_index.hpp>
5
6
/**
7
* @file type.h
8
* @brief 型名取得ユーティリティ
9
*
10
* Boost.TypeIndex を利用して、テンプレート引数の型名を
11
* CV修飾子・参照修飾子付きで人間が読みやすい文字列として返します。
12
*
13
* @note debug.h とは Boost ヘッダの依存関係を分離するために独立したファイルです
14
*/
15
16
/**
17
* @brief 変数の型名を文字列で返す
18
* @tparam T 型名を取得したい型(自動推論)
19
* @param (unnamed) 型を推論するための参照引数(値は使用しない)
20
* @return CV修飾・参照修飾を含む完全な型名文字列(例: "const int &")
21
*
22
* @code
23
* int x = 42;
24
* std::cout << getType(x); // "int"
25
* const double& r = 3.14;
26
* std::cout << getType(r); // "double const&"
27
* @endcode
28
*/
29
template
<
typename
T>
30
std::string
getType
(
const
T&) {
31
return
boost::typeindex::type_id_with_cvr<T>().pretty_name();
32
}
getType
std::string getType(const T &)
変数の型名を文字列で返す
Definition
type.h:30
type.h
構築:
1.14.0