43#ifndef MIO_SHARED_MMAP_HPP
44#define MIO_SHARED_MMAP_HPP
48#include <system_error>
60template <access_mode AccessMode,
typename ByteT>
64 std::shared_ptr<impl_type> pimpl_;
94 pimpl_ = std::make_shared<mmap_type>(std::move(
mmap));
104 pimpl_ = std::move(
mmap);
108#ifdef __cpp_exceptions
114 template <
typename String>
117 std::error_code
error;
120 throw std::system_error(
error);
131 std::error_code
error;
134 throw std::system_error(
error);
157 return pimpl_ ? pimpl_->file_handle() : invalid_handle;
161 return pimpl_ ? pimpl_->mapping_handle() : invalid_handle;
189 typename =
typename std::enable_if<A == access_mode::write>::type>
191 return pimpl_->data();
208 typename =
typename std::enable_if<A == access_mode::write>::type>
210 return pimpl_->end();
221 typename =
typename std::enable_if<A == access_mode::write>::type>
223 return pimpl_->rbegin();
233 typename =
typename std::enable_if<A == access_mode::write>::type>
235 return pimpl_->rend();
268 template <
typename String>
270 std::error_code&
error) {
286 template <
typename String>
311 std::error_code&
error) {
348 typename =
typename std::enable_if<A == access_mode::write>::type>
357 return a.pimpl_ ==
b.pimpl_;
365 return a.pimpl_ <
b.pimpl_;
369 return a.pimpl_ <=
b.pimpl_;
373 return a.pimpl_ >
b.pimpl_;
377 return a.pimpl_ >=
b.pimpl_;
381 template <
typename MappingToken>
383 std::error_code&
error) {
389 pimpl_ = std::make_shared<mmap_type>(std::move(
mmap));
400template <
typename ByteT>
407template <
typename ByteT>
Definition shared_mmap.hpp:62
friend bool operator!=(const basic_shared_mmap &a, const basic_shared_mmap &b)
Definition shared_mmap.hpp:360
const_iterator begin() const noexcept
Definition shared_mmap.hpp:200
const_reference operator[](const size_type &i) const noexcept
Definition shared_mmap.hpp:246
void map(const String &path, std::error_code &error)
Definition shared_mmap.hpp:287
typename impl_type::const_reference const_reference
Definition shared_mmap.hpp:70
size_type length() const noexcept
Definition shared_mmap.hpp:181
friend bool operator<(const basic_shared_mmap &a, const basic_shared_mmap &b)
Definition shared_mmap.hpp:364
typename impl_type::pointer pointer
Definition shared_mmap.hpp:71
void swap(basic_shared_mmap &other)
Definition shared_mmap.hpp:344
size_type mapped_length() const noexcept
Definition shared_mmap.hpp:182
typename impl_type::handle_type handle_type
Definition shared_mmap.hpp:79
const_iterator cend() const noexcept
Definition shared_mmap.hpp:213
void sync(std::error_code &error)
Definition shared_mmap.hpp:349
size_type size() const noexcept
Definition shared_mmap.hpp:180
const_iterator end() const noexcept
Definition shared_mmap.hpp:212
iterator begin() noexcept
Definition shared_mmap.hpp:199
friend bool operator==(const basic_shared_mmap &a, const basic_shared_mmap &b)
Definition shared_mmap.hpp:356
void map(const handle_type &handle, const size_type &offset, const size_type &length, std::error_code &error)
Definition shared_mmap.hpp:310
typename impl_type::const_reverse_iterator const_reverse_iterator
Definition shared_mmap.hpp:77
typename impl_type::value_type value_type
Definition shared_mmap.hpp:67
bool is_open() const noexcept
Definition shared_mmap.hpp:165
std::shared_ptr< mmap_type > get_shared_ptr()
Definition shared_mmap.hpp:147
const_pointer data() const noexcept
Definition shared_mmap.hpp:193
typename impl_type::const_iterator const_iterator
Definition shared_mmap.hpp:75
typename impl_type::reverse_iterator reverse_iterator
Definition shared_mmap.hpp:76
iterator end() noexcept
Definition shared_mmap.hpp:209
~basic_shared_mmap()=default
typename impl_type::const_pointer const_pointer
Definition shared_mmap.hpp:72
void map(const String &path, const size_type &offset, const size_type &length, std::error_code &error)
Definition shared_mmap.hpp:269
basic_shared_mmap(std::shared_ptr< mmap_type > mmap)
Definition shared_mmap.hpp:99
void unmap()
Definition shared_mmap.hpp:339
typename impl_type::reference reference
Definition shared_mmap.hpp:69
const_reverse_iterator rend() const noexcept
Definition shared_mmap.hpp:237
impl_type mmap_type
Definition shared_mmap.hpp:80
reverse_iterator rend() noexcept
Definition shared_mmap.hpp:234
pointer data() noexcept
Definition shared_mmap.hpp:190
basic_shared_mmap & operator=(mmap_type &&mmap)
Definition shared_mmap.hpp:93
friend bool operator<=(const basic_shared_mmap &a, const basic_shared_mmap &b)
Definition shared_mmap.hpp:368
friend bool operator>=(const basic_shared_mmap &a, const basic_shared_mmap &b)
Definition shared_mmap.hpp:376
basic_shared_mmap & operator=(basic_shared_mmap &&)=default
typename impl_type::difference_type difference_type
Definition shared_mmap.hpp:73
handle_type mapping_handle() const noexcept
Definition shared_mmap.hpp:160
const_iterator cbegin() const noexcept
Definition shared_mmap.hpp:201
const_reverse_iterator crbegin() const noexcept
Definition shared_mmap.hpp:226
basic_shared_mmap()=default
bool empty() const noexcept
Definition shared_mmap.hpp:172
const_reverse_iterator rbegin() const noexcept
Definition shared_mmap.hpp:225
friend bool operator>(const basic_shared_mmap &a, const basic_shared_mmap &b)
Definition shared_mmap.hpp:372
basic_shared_mmap & operator=(std::shared_ptr< mmap_type > mmap)
Definition shared_mmap.hpp:103
typename impl_type::iterator_category iterator_category
Definition shared_mmap.hpp:78
basic_shared_mmap(basic_shared_mmap &&)=default
typename impl_type::iterator iterator
Definition shared_mmap.hpp:74
typename impl_type::size_type size_type
Definition shared_mmap.hpp:68
const_reverse_iterator crend() const noexcept
Definition shared_mmap.hpp:238
basic_shared_mmap(mmap_type &&mmap)
Definition shared_mmap.hpp:89
basic_shared_mmap(const basic_shared_mmap &)=default
handle_type file_handle() const noexcept
Definition shared_mmap.hpp:156
basic_shared_mmap & operator=(const basic_shared_mmap &)=default
void map(const handle_type &handle, std::error_code &error)
Definition shared_mmap.hpp:326
reference operator[](const size_type &i) noexcept
Definition shared_mmap.hpp:245
reverse_iterator rbegin() noexcept
Definition shared_mmap.hpp:222
Definition string_util.hpp:48
access_mode
Definition page.hpp:59
@ map_entire_file
Definition mmap.hpp:68
std::random_access_iterator_tag iterator_category
Definition mmap.hpp:95
pointer iterator
Definition mmap.hpp:91
size_t size_type
Definition mmap.hpp:85
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition mmap.hpp:94
const_pointer const_iterator
Definition mmap.hpp:92
const value_type * const_pointer
Definition mmap.hpp:89
std::reverse_iterator< iterator > reverse_iterator
Definition mmap.hpp:93
std::ptrdiff_t difference_type
Definition mmap.hpp:90
const value_type & const_reference
Definition mmap.hpp:87
value_type * pointer
Definition mmap.hpp:88
value_type & reference
Definition mmap.hpp:86
file_handle_type handle_type
Definition mmap.hpp:96
ByteT value_type
Definition mmap.hpp:84