19#ifndef WP_ACCESS_HPP_INCLUDED
20#define WP_ACCESS_HPP_INCLUDED
23#include <system_error>
25#include "nonstd/expected.hpp"
33template <
typename R,
typename WP,
typename F>
34auto wp_access(
const WP& wp, F&& func) ->
35 nonstd::expected<R, std::error_code> {
36 if (
auto sp = wp.lock()) {
39 return nonstd::make_unexpected(std::make_error_code(net_ip_errc::weak_ptr_expired));
42template <
typename WP,
typename F>
43auto wp_access_void(
const WP& wp, F&& func) ->
44 nonstd::expected<void, std::error_code> {
45 if (
auto sp = wp.lock()) {
48 return nonstd::make_unexpected(r);
52 return nonstd::make_unexpected(std::make_error_code(net_ip_errc::weak_ptr_expired));
Error codes, exception class, and error category within Chops net_ip library.