Skip to content

Commit

Permalink
Fix compile on C++11; fix missing include.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 302729990
  • Loading branch information
hzeller committed Mar 24, 2020
1 parent 0dac7a3 commit 6b58e8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion common/strings/obfuscator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <string>

#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_split.h"
#include "absl/strings/string_view.h"
#include "common/util/logging.h"
Expand All @@ -29,7 +30,8 @@ bool Obfuscator::encode(absl::string_view key, absl::string_view value) {

absl::string_view Obfuscator::operator()(absl::string_view input) {
if (decode_mode) {
const auto p = translator_.find_reverse(input); // hetergeneous lookup
// TODO(b/152331548): make hetergeneous lookup work on C++11
const auto p = translator_.find_reverse(std::string(input));
return (p != nullptr) ? *p : input;
} else {
const std::string* str = translator_.insert_using_value_generator(
Expand Down
2 changes: 2 additions & 0 deletions common/util/bijective_map_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ TEST(BijectiveMapTest, InsertRandom) {
EXPECT_EQ(*ABSL_DIE_IF_NULL(m.insert_using_value_generator("f", gen)), 3);
}

#if 0 // TODO(b/152331548): make work with C++11
// Testing heterogenous lookup: internally stored std::string, supporting
// copy-less lookup with absl::string_view.
using StringMapType = BijectiveMap<std::string, std::string, StringViewCompare,
Expand All @@ -124,6 +125,7 @@ TEST(BijectiveMapTest, HeterogeneousStringLookup) {
EXPECT_EQ(m.find_forward(absl::string_view("b")), nullptr);
EXPECT_EQ(m.find_reverse(absl::string_view("3")), nullptr);
}
#endif

} // namespace
} // namespace verible

0 comments on commit 6b58e8f

Please sign in to comment.