mirror of
https://github.com/vimpunk/mio.git
synced 2025-12-06 16:57:01 +08:00
Fix char* being an invalid path type
This commit is contained in:
parent
307db6a136
commit
365a80c9ac
@ -26,10 +26,21 @@
|
||||
namespace mio {
|
||||
namespace detail {
|
||||
|
||||
template<typename String> struct is_c_str
|
||||
template <typename String>
|
||||
struct is_c_str
|
||||
{
|
||||
static constexpr bool value = std::is_same<
|
||||
const char*, typename std::decay<String>::type
|
||||
char*,
|
||||
// TODO: I'm so sorry for this... Can this be made cleaner?
|
||||
typename std::add_pointer<
|
||||
typename std::remove_cv<
|
||||
typename std::remove_pointer<
|
||||
typename std::decay<
|
||||
String
|
||||
>::type
|
||||
>::type
|
||||
>::type
|
||||
>::type
|
||||
>::value;
|
||||
};
|
||||
|
||||
|
||||
@ -22,7 +22,11 @@ using mmap_source = mio::basic_mmap_source<std::byte>;
|
||||
|
||||
int main()
|
||||
{
|
||||
const char* path = "test-file";
|
||||
const char _path[] = "test-file";
|
||||
// Make sure mio compiles with non-const char* strings too.
|
||||
const int path_len = sizeof(_path);
|
||||
char* path = new char[path_len];
|
||||
std::copy(_path, _path + path_len, path);
|
||||
std::error_code error;
|
||||
// Fill buffer, then write it to file.
|
||||
std::string buffer(0x4000 - 250, 'M');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user