Fix char* being an invalid path type

This commit is contained in:
mandreyel 2018-10-18 19:30:41 +02:00
parent 307db6a136
commit 365a80c9ac
2 changed files with 18 additions and 3 deletions

View File

@ -26,10 +26,21 @@
namespace mio { namespace mio {
namespace detail { namespace detail {
template<typename String> struct is_c_str template <typename String>
struct is_c_str
{ {
static constexpr bool value = std::is_same< 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; >::value;
}; };

View File

@ -22,7 +22,11 @@ using mmap_source = mio::basic_mmap_source<std::byte>;
int main() 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; std::error_code error;
// Fill buffer, then write it to file. // Fill buffer, then write it to file.
std::string buffer(0x4000 - 250, 'M'); std::string buffer(0x4000 - 250, 'M');