mirror of
https://github.com/vimpunk/mio.git
synced 2025-12-06 16:57:01 +08:00
Merge pull request #31 from easyaspi314/master
Conditionally enable the exception-throwing constructors
This commit is contained in:
commit
321bb4d89c
@ -50,6 +50,8 @@ or:
|
||||
```c++
|
||||
mmap.map(path, error);
|
||||
```
|
||||
**NOTE:** The constructors **require** exceptions to be enabled. If you prefer
|
||||
to build your projects with `-fno-exceptions`, you can still use the other ways.
|
||||
|
||||
Moreover, in each case, you can provide either some string type for the file's path, or you can use an existing, valid file handle.
|
||||
```c++
|
||||
|
||||
@ -103,6 +103,7 @@ public:
|
||||
*/
|
||||
basic_mmap() = default;
|
||||
|
||||
#ifdef __cpp_exceptions
|
||||
/**
|
||||
* The same as invoking the `map` function, except any error that may occur
|
||||
* while establishing the mapping is wrapped in a `std::system_error` and is
|
||||
@ -127,6 +128,7 @@ public:
|
||||
map(handle, offset, length, error);
|
||||
if(error) { throw std::system_error(error); }
|
||||
}
|
||||
#endif // __cpp_exceptions
|
||||
|
||||
/**
|
||||
* `basic_mmap` has single-ownership semantics, so transferring ownership
|
||||
|
||||
@ -87,6 +87,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef __cpp_exceptions
|
||||
/**
|
||||
* The same as invoking the `map` function, except any error that may occur
|
||||
* while establishing the mapping is wrapped in a `std::system_error` and is
|
||||
@ -111,6 +112,7 @@ public:
|
||||
map(handle, offset, length, error);
|
||||
if(error) { throw std::system_error(error); }
|
||||
}
|
||||
#endif // __cpp_exceptions
|
||||
|
||||
/**
|
||||
* If this is a read-write mapping and the last reference to the mapping,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user