Commit 8d53d77b authored by Lewis Baker's avatar Lewis Baker Committed by Facebook Github Bot

Fix property_set_insert_t metafunction in pushmi

Summary: The property_set_insert_t<PS1, PS2> template metafunction had a bug that meant that it would fail to replace elements in the base set that had the same category as elements from the set being inserted.

Reviewed By: ericniebler, kirkshoop

Differential Revision: D14268145

fbshipit-source-id: ccc64e455bc6ff2073229e028a19d64dc7050092
parent 973c5bb8
......@@ -120,7 +120,7 @@ POut __property_set_index_fn(
property_set_element<POut, property_category_t<PIn>>);
template <class PIn, class POut, class... Ps>
property_set<std::conditional_t<PUSHMI_PP_IS_SAME(Ps, PIn), POut, Ps>...>
property_set<std::conditional_t<PUSHMI_PP_IS_SAME(Ps, POut), PIn, Ps>...>
__property_set_insert_fn(
property_set<Ps...>,
property_set_element<POut, property_category_t<PIn>>);
......
/*
* Copyright 2019-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/experimental/pushmi/properties.h>
namespace {
struct foo_category;
struct bar_category;
struct big_foo_property {
using property_category = foo_category;
};
struct small_foo_property {
using property_category = foo_category;
};
struct fast_bar_property {
using property_category = bar_category;
};
struct slow_bar_property {
using property_category = bar_category;
};
} // namespace
using namespace folly::pushmi;
////////////////
// Tests for property_set_insert_t<PS1, PS2>
static_assert(
std::is_same<
property_set<big_foo_property>,
property_set_insert_t<property_set<>, property_set<big_foo_property>>>::
value, "");
static_assert(std::is_same<
property_set<big_foo_property>,
property_set_insert_t<
property_set<big_foo_property>,
property_set<big_foo_property>>>::value, "");
static_assert(
std::is_same<
property_set<big_foo_property>,
property_set_insert_t<property_set<big_foo_property>, property_set<>>>::
value, "");
static_assert(std::is_same<
property_set<big_foo_property>,
property_set_insert_t<
property_set<small_foo_property>,
property_set<big_foo_property>>>::value, "");
static_assert(std::is_same<
property_set<big_foo_property, slow_bar_property>,
property_set_insert_t<
property_set<big_foo_property, slow_bar_property>,
property_set<big_foo_property>>>::value, "");
static_assert(std::is_same<
property_set<big_foo_property, slow_bar_property>,
property_set_insert_t<
property_set<small_foo_property, slow_bar_property>,
property_set<big_foo_property>>>::value, "");
static_assert(std::is_same<
property_set<slow_bar_property, big_foo_property>,
property_set_insert_t<
property_set<slow_bar_property>,
property_set<big_foo_property>>>::value, "");
int main() {
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment