xo-umbrella2/xo-alloc2/include/xo/alloc2/role.hpp
Roland Conybeare 6a82040d48 git subrepo clone git@github.com:Rconybea/xo-alloc2.git xo-alloc2
subrepo:
  subdir:   "xo-alloc2"
  merged:   "4039c29f"
upstream:
  origin:   "git@github.com:Rconybea/xo-alloc2.git"
  branch:   "main"
  commit:   "4039c29f"
git-subrepo:
  version:  "0.4.9"
  origin:   "???"
  commit:   "???"
2026-06-06 22:01:14 -04:00

40 lines
991 B
C++

/** @file role.hpp
*
* @author Roland Conybeare, Dec 2025
**/
#pragma once
#include <array>
#include <cstdint>
namespace xo {
namespace mm {
static constexpr uint32_t c_n_role = 2;
/** @brief identify GC half-spaces
**/
class Role {
public:
using value_type = std::uint32_t;
explicit constexpr Role(value_type x) : role_{x} {}
static constexpr Role to_space() { return Role{0}; }
static constexpr Role from_space() { return Role{1}; }
static constexpr std::array<Role, c_n_role> all() { return {{to_space(), from_space()}}; }
static constexpr Role begin() { return Role{0}; }
static constexpr Role end() { return Role{2}; }
operator value_type() const { return role_; }
Role next() const { return Role(role_ + 1); }
value_type role_ = 0;
};
} /*namespace mm*/
} /*namespace xo*/
/* end role.hpp */