Skip to content

Commit

Permalink
Workaround a compilation issue on C++20
Browse files Browse the repository at this point in the history
Summary: Workaround a compilation issue on C++20 by switching from `fmt::string_view` to `boost::string_view`. A proper fix (fmtlib/fmt#2769) will be backported separately.

Differential Revision: D37076763

fbshipit-source-id: d8001bdcd65ee9edf1f265e3aaf281c196e4d155
  • Loading branch information
vitaut authored and facebook-github-bot committed Jun 10, 2022
1 parent 334a191 commit 4605cfa
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion thrift/compiler/generate/t_mstch_cpp2_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class mstch_cpp2_type : public mstch_type {
return resolved_type_->is_string_or_binary() && !is_adapted();
}
mstch::node resolved_cpp_type() {
return fmt::to_string(cpp2::get_type(resolved_type_));
return std::string(cpp2::get_type(resolved_type_));
}
mstch::node is_string_or_binary() {
return resolved_type_->is_string_or_binary();
Expand Down
2 changes: 1 addition & 1 deletion thrift/compiler/generate/t_mstch_py3_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ std::shared_ptr<mstch_base> type_py3_generator<ForContainers>::generate(
trueType,
mstch_py3_type::CachedProperties{
get_cpp_template(*trueType),
fmt::to_string(cpp2::get_type(trueType)),
std::string(cpp2::get_type(trueType)),
{}});
}
return std::make_shared<T>(
Expand Down
8 changes: 4 additions & 4 deletions thrift/compiler/lib/cpp2/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ namespace compiler {
namespace cpp2 {
namespace {

bool contains(fmt::string_view s, fmt::string_view what) {
bool contains(boost::string_view s, boost::string_view what) {
return std::search(s.begin(), s.end(), what.begin(), what.end()) != s.end();
}

fmt::string_view value_or_empty(const std::string* value) {
return value ? *value : std::string_view("");
boost::string_view value_or_empty(const std::string* value) {
return value ? *value : boost::string_view("");
}

int checked_stoi(const std::string& s, std::string msg) {
Expand Down Expand Up @@ -258,7 +258,7 @@ bool is_orderable(t_type const& type) {
return is_orderable(seen, memo, type);
}

fmt::string_view get_type(const t_type* type) {
boost::string_view get_type(const t_type* type) {
return value_or_empty(gen::cpp::type_resolver::find_type(*type));
}

Expand Down
4 changes: 2 additions & 2 deletions thrift/compiler/lib/cpp2/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <thrift/compiler/gen/cpp/namespace_resolver.h>
#include <thrift/compiler/gen/cpp/reference_type.h>

#include <fmt/format.h>
#include <boost/utility/string_view.hpp>

namespace apache {
namespace thrift {
Expand Down Expand Up @@ -101,7 +101,7 @@ bool is_orderable(t_type const& type);
* Return the cpp.type/cpp2.type attribute or empty string if nothing set.
*/
// TODO(afuller): Replace with type_resolver::get_type_name.
fmt::string_view get_type(const t_type* type);
boost::string_view get_type(const t_type* type);

/**
* If the cpp_type is std::unique_ptr<folly::IOBuf> the C++ compiler implicitly
Expand Down

0 comments on commit 4605cfa

Please sign in to comment.