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::memalignment - cpprefjp C++日本語リファレンス

  1. リファレンス
  2. cstdlib
  3. memalignment

最終更新日時: 2026年06月15日 14時22分22秒 (JST)
Akira Takahashi が更新

履歴 編集

function
<cstdlib>

std::memalignment(C++26)

namespace std {
  size_t memalignment(const void* p);
}

概要

ポインタのアライメントを取得する。

C23で<stdlib.h>に追加された関数であり、C++26で<cstdlib>に取り込まれた。

この関数はフリースタンディング環境でも提供される。

戻り値

  • pがヌルポインタでない場合、ポインタ値pを割り切ることができる最大の2の累乗の値を返す
  • pがヌルポインタの場合、0を返す

例

#include <cstdlib>
#include <print>

int main()
{
  void* p = std::aligned_alloc(64, 256);
  std::println("{}", std::memalignment(p));
  std::free(p);
}

出力例

64

バージョン

言語

  • C++26

処理系

  • Clang: 22 ❌
  • GCC: 16.1 ❌
  • Visual C++: 2026 Update 2 ❌

関連項目

  • aligned_alloc(): 指定したアライメントでメモリを確保する
  • free_aligned_sized(): アライメントと確保時のサイズを指定して、確保したメモリを解放する

参照

  • P3348R4 C++26 should refer to C23 not C17
    • C++26がC23を参照するようになり、この関数が<cstdlib>に追加された
You are visitor 01402520 — 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.