API Reference¶
All declarations reside in namespace siddiqsoft.
Header¶
Classes¶
class timethis¶
RAII-based stopwatch class measuring elapsed time with optional callback invocation on destruction.
Type Aliases¶
| Alias | Definition | Description |
|---|---|---|
duration_type |
std::chrono::system_clock::duration |
System clock duration type used for elapsed measurements |
time_point_type |
std::chrono::system_clock::time_point |
Time point type captured upon construction or reset |
callback_type |
std::function<void(const std::chrono::system_clock::duration&)> |
Callback invoked with elapsed duration upon destruction |
Constructors & Destructor¶
Constructs the timer, capturing the current time and caller source location.explicit timethis(callback_type&& callback,
const std::source_location& sl = std::source_location::current()) noexcept;
elapsed().
Semantics (Copy & Move)¶
timethis(const timethis&) = delete;
timethis& operator=(const timethis&) = delete;
timethis(timethis&&) = delete;
timethis& operator=(timethis&&) = delete;
Member Functions¶
elapsed()¶
Calculates and returns the duration elapsed since construction or the last reset().
lap()¶
Returns elapsed time formatted as a numeric string in the duration unit specified by DC (defaults to std::chrono::microseconds).
to_string()¶
Returns a human-readable string containing the source location function name, start timestamp, and elapsed microseconds.
reset()¶
Resets the timer's start time to the current clock time.
Stream & Formatter Support¶
Stream Operator¶
Writes<function_name> took <elapsed>ns to the output stream.
std::formatter Specialization¶
Enables direct formatting via std::format("{}", timer) matching to_string().