JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
string_view.h File Reference

POD-safe string_view with full constexpr semantics and consteval/runtime dual-path optimization. More...

#include <algorithm>
#include <compare>
#include <cstdint>
#include <cstring>
#include <string_view>
#include <type_traits>
#include <cstddef>
#include "jh/metax/char.h"
#include "jh/pods/pod_like.h"
#include "jh/detail/base64_common.h"
#include "jh/metax/hash.h"

Go to the source code of this file.

Classes

struct  jh::pod::string_view
 Read-only string view with POD layout. More...

Namespaces

namespace  jh::pod
 Aggregated entry point for Plain-Old-Data and layout-stable value utilities.
namespace  jh::pod::literals
 Official literal helpers for jh::pod types.

Functions

constexpr jh::pod::string_view jh::pod::literals::operator""_psv (const char *str, std::size_t len) noexcept
 User-defined literal for jh::pod::string_view.

Detailed Description

POD-safe string_view with full constexpr semantics and consteval/runtime dual-path optimization.

This header defines a lightweight, read-only, non-owning string view specifically designed for POD-compatible use cases, offering constexpr evaluation and optimized runtime behavior.

Highlights:

  • POD layout: strictly { const char*, uint64_t }
  • All operations constexpr: usable in both compile-time (consteval) and runtime contexts
  • Dual-path design:
    • Constexpr-safe logic for compile-time evaluation
    • Accelerated runtime path using memcmp / memcpy
  • Deep comparison via memcmp, not pointer identity
  • Constexpr hash supported — usable in consteval expressions
  • Designed as a safe view type for immutable_str and POD containers

Usage Notes:

  • Provides zero-overhead interop with std::string_view
  • Supports compile-time construction via from_literal() or "..."_psv
  • No dynamic allocation, no exceptions, fully constexpr evaluable
  • Enables compile-time hashing (e.g., jh::meta::t_str)