Porytiles
Loading...
Searching...
No Matches
porytiles2::StringViewSourceLoc Struct Reference

A wrapper for std::string_view with a taggable std::source_location. More...

#include <panic.hpp>

Collaboration diagram for porytiles2::StringViewSourceLoc:
[legend]

Public Member Functions

template<class T >
requires std::constructible_from<std::string_view, T>
 StringViewSourceLoc (const T &msg, const std::source_location loc=std::source_location::current()) noexcept
 Constructs a StringViewSourceLoc with a message and optional source location.
 

Public Attributes

std::string_view msg_
 
std::source_location loc_
 

Detailed Description

A wrapper for std::string_view with a taggable std::source_location.

This struct combines a message with source location information for debugging and error reporting. It automatically captures the source location at the point of construction when used with the default parameter. Inspired by: https://buildingblock.ai/panic

Definition at line 20 of file panic.hpp.

Constructor & Destructor Documentation

◆ StringViewSourceLoc()

template<class T >
requires std::constructible_from<std::string_view, T>
porytiles2::StringViewSourceLoc::StringViewSourceLoc ( const T &  msg,
const std::source_location  loc = std::source_location::current() 
)
inlinenoexcept

Constructs a StringViewSourceLoc with a message and optional source location.

The constructor accepts any type that can be converted to std::string_view and automatically captures the source location if not explicitly provided.

Template Parameters
TType that can be constructed into std::string_view
Parameters
msgThe message to store
locThe source location (defaults to current location)

Definition at line 35 of file panic.hpp.

Member Data Documentation

◆ loc_

std::source_location porytiles2::StringViewSourceLoc::loc_

Definition at line 41 of file panic.hpp.

◆ msg_

std::string_view porytiles2::StringViewSourceLoc::msg_

Definition at line 40 of file panic.hpp.


The documentation for this struct was generated from the following file: