Skip to content

Commit 06b3bab

Browse files
committed
Also support <filesystem> as well as <experimental/filesystem>
The change for <coroutine> vs. <experimental/coroutine> is replicated for <filesystem> in this patch. In addition, the std::experimental namespace is replaced by cppcoro:: namespace in a few more places.
1 parent 49da236 commit 06b3bab

8 files changed

+46
-20
lines changed

Diff for: README.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,15 @@ namespace cppcoro
714714
{
715715
public:
716716
bool await_ready() const noexcept;
717-
bool await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
717+
bool await_suspend(cppcoro::coroutine_handle<> awaiter) noexcept;
718718
void await_resume() const noexcept;
719719
};
720720

721721
class async_mutex_scoped_lock_operation
722722
{
723723
public:
724724
bool await_ready() const noexcept;
725-
bool await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
725+
bool await_suspend(cppcoro::coroutine_handle<> awaiter) noexcept;
726726
[[nodiscard]] async_mutex_lock await_resume() const noexcept;
727727
};
728728

@@ -836,7 +836,7 @@ namespace cppcoro
836836
async_manual_reset_event_operation(async_manual_reset_event& event) noexcept;
837837

838838
bool await_ready() const noexcept;
839-
bool await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
839+
bool await_suspend(cppcoro::coroutine_handle<> awaiter) noexcept;
840840
void await_resume() const noexcept;
841841
};
842842
}
@@ -904,7 +904,7 @@ namespace cppcoro
904904
async_auto_reset_event_operation(const async_auto_reset_event_operation& other) noexcept;
905905
906906
bool await_ready() const noexcept;
907-
bool await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
907+
bool await_suspend(cppcoro::coroutine_handle<> awaiter) noexcept;
908908
void await_resume() const noexcept;
909909
910910
};
@@ -1389,7 +1389,7 @@ namespace cppcoro
13891389
schedule_operation(static_thread_pool* tp) noexcept;
13901390
13911391
bool await_ready() noexcept;
1392-
bool await_suspend(std::experimental::coroutine_handle<> h) noexcept;
1392+
bool await_suspend(cppcoro::coroutine_handle<> h) noexcept;
13931393
bool await_resume() noexcept;
13941394
13951395
private:
@@ -1546,7 +1546,7 @@ namespace cppcoro
15461546
schedule_operation& operator=(const schedule_operation&) noexcept;
15471547

15481548
bool await_ready() const noexcept;
1549-
void await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
1549+
void await_suspend(cppcoro::coroutine_handle<> awaiter) noexcept;
15501550
void await_resume() noexcept;
15511551
};
15521552

@@ -1560,7 +1560,7 @@ namespace cppcoro
15601560
timed_schedule_operation& operator=(timed_schedule_operation&&) = delete;
15611561

15621562
bool await_ready() const noexcept;
1563-
void await_suspend(std::experimental::coroutine_handle<> awaiter);
1563+
void await_suspend(cppcoro::coroutine_handle<> awaiter);
15641564
void await_resume();
15651565
};
15661566

@@ -1591,12 +1591,12 @@ Example:
15911591
#include <cppcoro/io_service.hpp>
15921592
#include <cppcoro/read_only_file.hpp>
15931593
1594-
#include <experimental/filesystem>
1594+
#include <cppcoro/filesystem.hpp>
15951595
#include <memory>
15961596
#include <algorithm>
15971597
#include <iostream>
15981598
1599-
namespace fs = std::experimental::filesystem;
1599+
namespace fs = cppcoro::filesystem;
16001600
16011601
cppcoro::task<std::uint64_t> count_lines(cppcoro::io_service& ioService, fs::path path)
16021602
{
@@ -1740,7 +1740,7 @@ namespace cppcoro
17401740
file_read_operation(file_read_operation&& other) noexcept;
17411741
17421742
bool await_ready() const noexcept;
1743-
bool await_suspend(std::experimental::coroutine_handle<> awaiter);
1743+
bool await_suspend(cppcoro::coroutine_handle<> awaiter);
17441744
std::size_t await_resume();
17451745
17461746
};
@@ -1752,7 +1752,7 @@ namespace cppcoro
17521752
file_write_operation(file_write_operation&& other) noexcept;
17531753
17541754
bool await_ready() const noexcept;
1755-
bool await_suspend(std::experimental::coroutine_handle<> awaiter);
1755+
bool await_suspend(cppcoro::coroutine_handle<> awaiter);
17561756
std::size_t await_resume();
17571757
17581758
};
@@ -1774,7 +1774,7 @@ namespace cppcoro
17741774
[[nodiscard]]
17751775
static read_only_file open(
17761776
io_service& ioService,
1777-
const std::experimental::filesystem::path& path,
1777+
const cppcoro::filesystem::path& path,
17781778
file_share_mode shareMode = file_share_mode::read,
17791779
file_buffering_mode bufferingMode = file_buffering_mode::default_);
17801780

@@ -1787,7 +1787,7 @@ namespace cppcoro
17871787
[[nodiscard]]
17881788
static write_only_file open(
17891789
io_service& ioService,
1790-
const std::experimental::filesystem::path& path,
1790+
const cppcoro::filesystem::path& path,
17911791
file_open_mode openMode = file_open_mode::create_or_open,
17921792
file_share_mode shareMode = file_share_mode::none,
17931793
file_buffering_mode bufferingMode = file_buffering_mode::default_);
@@ -1801,7 +1801,7 @@ namespace cppcoro
18011801
[[nodiscard]]
18021802
static read_write_file open(
18031803
io_service& ioService,
1804-
const std::experimental::filesystem::path& path,
1804+
const cppcoro::filesystem::path& path,
18051805
file_open_mode openMode = file_open_mode::create_or_open,
18061806
file_share_mode shareMode = file_share_mode::none,
18071807
file_buffering_mode bufferingMode = file_buffering_mode::default_);
@@ -2794,7 +2794,7 @@ coroutine.
27942794

27952795
A type that satisfies `Awaiter<T>` must have, for an instance of the type, `awaiter`:
27962796
- `awaiter.await_ready()` -> `bool`
2797-
- `awaiter.await_suspend(std::experimental::coroutine_handle<void>{})` -> `void` or `bool` or `std::experimental::coroutine_handle<P>` for some `P`.
2797+
- `awaiter.await_suspend(cppcoro::coroutine_handle<void>{})` -> `void` or `bool` or `cppcoro::coroutine_handle<P>` for some `P`.
27982798
- `awaiter.await_resume()` -> `T`
27992799

28002800
Any type that implements the `Awaiter<T>` concept also implements the `Awaitable<T>` concept.

Diff for: include/cppcoro/coroutine.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace cppcoro {
1111

1212
using suspend_always = std::suspend_always;
1313
using suspend_never = std::suspend_never;
14+
static inline auto noop_coroutine() { return std::noop_coroutine(); }
1415
}
1516

1617
#elif __has_include(<experimental/coroutine>)
@@ -23,6 +24,7 @@ namespace cppcoro {
2324

2425
using suspend_always = std::experimental::suspend_always;
2526
using suspend_never = std::experimental::suspend_never;
27+
static inline auto noop_coroutine() { return std::experimental::noop_coroutine(); }
2628
}
2729

2830
#else

Diff for: include/cppcoro/file.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# include <cppcoro/detail/win32.hpp>
1616
#endif
1717

18-
#include <experimental/filesystem>
18+
#include <cppcoro/filesystem.hpp>
1919

2020
namespace cppcoro
2121
{

Diff for: include/cppcoro/filesystem.hpp

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef CPPCORO_FILESYSTEM_HPP_INCLUDED
2+
#define CPPCORO_FILESYSTEM_HPP_INCLUDED
3+
4+
#if __has_include(<filesystem>)
5+
6+
#include <filesystem>
7+
8+
namespace cppcoro {
9+
namespace filesystem = std::filesystem;
10+
}
11+
12+
#elif __has_include(<experimental/filesystem>)
13+
14+
#include <experimental/filesystem>
15+
16+
namespace cppcoro {
17+
namespace filesystem = std::experimental::filesystem;
18+
}
19+
20+
#else
21+
#error Cppcoro requires a C++20 compiler with filesystem support
22+
#endif
23+
24+
#endif

Diff for: include/cppcoro/net/socket_accept_operation.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# include <atomic>
1717
# include <optional>
18-
# include <experimental/coroutine>
18+
# include <cppcoro/coroutine.hpp>
1919

2020
namespace cppcoro
2121
{

Diff for: include/cppcoro/read_only_file.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <cppcoro/file_share_mode.hpp>
1010
#include <cppcoro/file_buffering_mode.hpp>
1111

12-
#include <experimental/filesystem>
12+
#include <cppcoro/filesystem.hpp>
1313

1414
namespace cppcoro
1515
{

Diff for: include/cppcoro/read_write_file.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <cppcoro/file_buffering_mode.hpp>
1212
#include <cppcoro/file_open_mode.hpp>
1313

14-
#include <experimental/filesystem>
14+
#include <cppcoro/filesystem.hpp>
1515

1616
namespace cppcoro
1717
{

Diff for: include/cppcoro/write_only_file.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <cppcoro/file_buffering_mode.hpp>
1111
#include <cppcoro/file_open_mode.hpp>
1212

13-
#include <experimental/filesystem>
13+
#include <cppcoro/filesystem.hpp>
1414

1515
namespace cppcoro
1616
{

0 commit comments

Comments
 (0)