Workaround MSVC 15.8 regressions.

This commit is contained in:
John Preston 2018-08-14 22:12:41 +03:00
parent f76a2bc224
commit fddc3d6ad9
5 changed files with 27 additions and 8 deletions

View file

@ -127,15 +127,16 @@ Ui::RpWidget *ContentWidget::doSetInnerWidget(
_innerWrap ? _innerWrap->padding() : style::margins()));
_innerWrap->move(0, 0);
// MSVC BUG + REGRESSION rpl::mappers::tuple :(
rpl::combine(
_scroll->scrollTopValue(),
_scroll->heightValue(),
_innerWrap->entity()->desiredHeightValue(),
tuple(_1, _1 + _2, _3)
_innerWrap->entity()->desiredHeightValue()
) | rpl::start_with_next([this](
int top,
int bottom,
int height,
int desired) {
const auto bottom = top + height;
_innerDesiredHeight = desired;
_innerWrap->setVisibleTopBottom(top, bottom);
_scrollTillBottomChanges.fire_copy(std::max(desired - bottom, 0));

View file

@ -296,6 +296,7 @@ MainWidget::MainWidget(
checkFloatPlayerVisibility();
});
// MSVC BUG + REGRESSION rpl::mappers::tuple :(
using namespace rpl::mappers;
_controller->activeChatValue(
) | rpl::map([](Dialogs::Key key) {
@ -303,7 +304,11 @@ MainWidget::MainWidget(
auto canWrite = peer
? Data::CanWriteValue(peer)
: rpl::single(false);
return std::move(canWrite) | rpl::map(tuple(key, _1));
return std::move(
canWrite
) | rpl::map([=](bool can) {
return std::make_tuple(key, can);
});
}) | rpl::flatten_latest(
) | rpl::start_with_next([this](Dialogs::Key key, bool canWrite) {
updateThirdColumnToCurrentChat(key, canWrite);

View file

@ -301,12 +301,13 @@ void Panel::refreshList() {
_scroll->scrollToY(newScrollTop);
}, weak->lifetime());
// MSVC BUG + REGRESSION rpl::mappers::tuple :(
using namespace rpl::mappers;
rpl::combine(
_scroll->scrollTopValue(),
_scroll->heightValue(),
tuple(_1, _1 + _2)
) | rpl::start_with_next([=](int top, int bottom) {
_scroll->heightValue()
) | rpl::start_with_next([=](int top, int height) {
const auto bottom = top + height;
weak->setVisibleTopBottom(top, bottom);
}, weak->lifetime());

View file

@ -367,6 +367,15 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
using namespace mappers;
// MSVC BUG + REGRESSION rpl::mappers::tuple :(
//combine(
// a.events(),
// b.events(),
// tuple(_1, _1 + _2)
//) | rpl::start_with_next([=](int a, int a_plus_b) {
// *sum += std::to_string(a * a_plus_b);
//}, lifetime);
combine(
a.events(),
b.events(),
@ -384,6 +393,9 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
c.fire(6);
}
REQUIRE(*sum == "16192225");
// MSVC BUG + REGRESSION rpl::mappers::tuple :(
//REQUIRE(*sum == "3162419362225");
}
SECTION("after_next test") {

View file

@ -43,7 +43,7 @@ public:
_clickedCallback = std::move(callback);
}
auto clicks() const {
rpl::producer<> clicks() const {
return _clicks.events();
}
template <typename Handler>