Skip to content

Commit b218ae1

Browse files
Use for
1 parent 21870be commit b218ae1

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ See [examples](https://github.com/andreiavrammsd/cpp-channel/tree/master/example
139139

140140
## Known limitations
141141

142-
* Integration with some STD algorithms does not compile with MSVC
142+
* Integration with some [STD algorithms](https://github.com/andreiavrammsd/cpp-channel/blob/master/examples/merge_channels.cpp) does not compile with MSVC
143143

144144
<br>
145145

tests/channel_test.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,19 @@ TEST(ChannelTest, Transform)
382382

383383
// Transform input channel values from movable_only to int by multiplying by 2 and write to output channel
384384
const auto double_transformer = [&input_chan, &output_chan]() {
385-
std::transform(input_chan.begin(), input_chan.end(), msd::back_inserter(output_chan),
386-
[](auto&& value) { return value.getValue() * 2; });
385+
const auto double_value = [](auto&& value) { return value.getValue() * 2; };
386+
#ifdef _MSC_VER
387+
for (auto&& value : input_chan) {
388+
output_chan.write(double_value(value));
389+
}
390+
391+
// Does not work with std::transform: warning C4702: unreachable code
392+
// -- Building for: Visual Studio 17 2022
393+
// -- The C compiler identification is MSVC 19.43.34808.0
394+
// -- The CXX compiler identification is MSVC 19.43.34808.0
395+
#else
396+
std::transform(input_chan.begin(), input_chan.end(), msd::back_inserter(output_chan), double_value);
397+
#endif // _MSC_VER
387398

388399
output_chan.close();
389400
};

0 commit comments

Comments
 (0)