Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 1.21 KB

File metadata and controls

60 lines (44 loc) · 1.21 KB

define_static_object

  • meta[meta header]
  • std[meta namespace]
  • function template[meta id-type]
  • cpp26[meta cpp]
namespace std {
  template <class T>
  consteval const remove_cvref_t<T>* define_static_object(T&& t);
}

概要

コンパイル時に計算したオブジェクトを静的ストレージに配置し、そのポインタを返す。

戻り値

tのコピーを保持する静的ストレージ上のオブジェクトへのポインタを返す。

#include <meta>
#include <print>

struct Config {
  int width;
  int height;
};

int main() {
  constexpr auto* p = std::define_static_object(Config{1920, 1080});
  std::println("{}x{}", p->width, p->height);
}

出力

1920x1080

バージョン

言語

  • C++26

処理系

関連項目

参照