Skip to content

Commit

Permalink
add missing include file
Browse files Browse the repository at this point in the history
Summary: Without this, we couldn't include `for_each.h` before generated `_for_each_field.h`. Otherwise it's build-error due to missing type.

Reviewed By: iahs

Differential Revision: D23250681

fbshipit-source-id: 70455a2b1c0be919c253ded55ed3b982a2ea8d0e
  • Loading branch information
Mizuchi authored and facebook-github-bot committed Aug 23, 2020
1 parent a63f694 commit 76e4080
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions thrift/lib/cpp2/visitation/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include <folly/Indestructible.h>
#include <thrift/lib/cpp2/gen/module_metadata_h.h>
#include <thrift/lib/thrift/gen-cpp2/metadata_types.h>

namespace apache {
Expand Down
38 changes: 38 additions & 0 deletions thrift/test/visitation_for_each_include_order_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* 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.
*/

// Test whether it works if we include for_each.h first.
#include <thrift/lib/cpp2/visitation/for_each.h>

#include <thrift/test/gen-cpp2/reflection_for_each_field.h>

#include <folly/String.h>
#include <folly/portability/GTest.h>

using namespace apache::thrift;
using namespace test_cpp2::cpp_reflection;

TEST(structA, test) {
structA s;
s.a_ref() = 1;
s.b_ref() = "1";
for_each_field(s, [](auto&&, auto ref) {
EXPECT_EQ(folly::to<std::string>(*ref), "1");
ref = folly::to<typename decltype(ref)::value_type>(2);
});
EXPECT_EQ(s.a_ref(), 2);
EXPECT_EQ(s.b_ref(), "2");
}

0 comments on commit 76e4080

Please sign in to comment.