function::get_sa_handler - Linux


Overview

function::get_sa_handler retrieves the function-scoped allocator (FSA) handler associated with a specified function.

Syntax

sa_handler = function::get_sa_handler(function)

Parameters:

  • function – A valid function object.

Return Value:

  • A sa_handler object representing the FSA handler associated with the given function, or nullptr if no FSA handler is associated with the function.

Options/Flags

None.

Examples

  1. Getting and displaying the FSA handler for a function:
#include <experimental/function>

int main() {
  std::function<int()> f = []() { return 42; };
  auto sa_handler = function::get_sa_handler(f);
  std::cout << "FSA handler: " << sa_handler << '\n';
  return 0;
}
  1. Checking if a function has an FSA handler:
#include <experimental/function>

int main() {
  std::function<int()> f = []() { return 42; };
  bool has_sa_handler = function::get_sa_handler(f) != nullptr;
  std::cout << "Has FSA handler: " << (has_sa_handler ? "true" : "false") << '\n';
  return 0;
}

Common Issues

None.

Integration

function::get_sa_handler can be used to diagnose issues or debug code involving FSA handlers.

Related Commands

  • function::is_sa_handler_used – Checks if an FSA handler is used for a function.