Skip to content

Commit 3c302cc

Browse files
Add explicit instantiation
1 parent ac55b79 commit 3c302cc

File tree

1 file changed

+11
-34
lines changed

1 file changed

+11
-34
lines changed

tests/channel_test.cpp

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,15 @@ class MovableOnly {
359359
int value{0};
360360
};
361361

362+
template msd::blocking_writer_iterator<msd::channel<int>>& msd::blocking_writer_iterator<msd::channel<int>>::operator=
363+
<int>(int&&);
364+
365+
template msd::blocking_writer_iterator<msd::channel<int>>& msd::blocking_writer_iterator<msd::channel<int>>::operator=
366+
<const int&>(const int&);
367+
368+
template bool msd::channel<int>::write(int&&);
369+
template bool msd::channel<int>::write(const int&);
370+
362371
TEST(ChannelTest, Transform)
363372
{
364373
const int numbers = 100;
@@ -379,40 +388,8 @@ TEST(ChannelTest, Transform)
379388

380389
// Transform input channel values from MovableOnly to int by multiplying by 2 and write to output channel
381390
const auto double_transformer = [&input_chan, &output_chan]() {
382-
const auto double_value = [](auto&& value) -> int { return value.getValue() * 2; };
383-
384-
#ifdef _MSC_VER
385-
for (auto&& value : input_chan) {
386-
output_chan.write(double_value(value));
387-
}
388-
389-
// Does not work with std::transform:
390-
//
391-
// could be 'void std::queue<T,std::deque<T,std::allocator<int>>>::push(int &&)'
392-
// with
393-
// [
394-
// T=ChannelTest_Traits_Test::TestBody::type
395-
// ]
396-
// D:\a\cpp-channel\cpp-channel\include\msd\channel.hpp(105,20):
397-
// 'void std::queue<T,std::deque<T,std::allocator<int>>>::push(int &&)': cannot convert argument 1 from
398-
// '_OutIt' to 'int &&' with
399-
// [
400-
// T=ChannelTest_Traits_Test::TestBody::type
401-
// ]
402-
// and
403-
// [
404-
// _OutIt=msd::blocking_writer_iterator<msd::channel<ChannelTest_Traits_Test::TestBody::type>>
405-
// ]
406-
// D:\a\cpp-channel\cpp-channel\include\msd\channel.hpp(105,43):
407-
// Reason: cannot convert from '_OutIt' to 'int'
408-
// with
409-
// [
410-
// _OutIt=msd::blocking_writer_iterator<msd::channel<ChannelTest_Traits_Test::TestBody::type>>
411-
// ]
412-
#else
413-
std::transform(input_chan.begin(), input_chan.end(), msd::back_inserter(output_chan), double_value);
414-
#endif // _MSC_VER
415-
391+
std::transform(input_chan.begin(), input_chan.end(), msd::back_inserter(output_chan),
392+
[](auto&& value) -> int { return value.getValue() * 2; });
416393
output_chan.close();
417394
};
418395

0 commit comments

Comments
 (0)