backport from main

This commit is contained in:
Mizux Seiha
2025-02-25 16:04:20 +01:00
parent c96c824034
commit 80686581f4
30 changed files with 149 additions and 130 deletions

View File

@@ -19,6 +19,7 @@
#include <functional>
#include <utility>
#include "absl/base/log_severity.h"
#include "absl/functional/function_ref.h"
#include "absl/log/check.h"
#include "absl/numeric/int128.h"
@@ -26,22 +27,29 @@
#include "ortools/base/logging.h"
namespace operations_research {
// Finds a point in [x_true, x_false) where f changes from true to false.
// If check_bounds is true, it will CHECK that f(x_true) = true and
// f(x_false) = false.
//
// EXAMPLE:
// // Finds the value x in [0,Pi/2] such that cos(x)=2sin(x):
// BinarySearch<double>(/*x_true=*/0.0, /*x_false=*/M_PI/2,
// [](double x) { return cos(x) >= 2*sin(x); });
//
// Note that x_true > x_false is supported: it works either way.
// MONOTONIC FUNCTIONS: Suppose f is a monotonic boolean function. See below for
// the NON-MONOTONIC case.
//
// Ideally, f is a monotonic boolean function, such that:
// - f(x_true) = true
// - f(x_false) = false
// - there exists X such that f(x)=true for all x between x_true and X, and
// f(x)=false for all x between X and x_false.
// If x_true < x_false, this returns X such that:
// - x_true < X < x_false,
// - f((x_true, X]) = true (i.e. for all x in (x_true, X], f(x) = true),
// - f((X, x_false)) = false (i.e. for all x in (X, x_false), f(x) = false)
// or this returns x_true if such an X does not exist.
//
// In those conditions, this returns that value X (note that f(X) is true).
// See below for the NON-MONOTONIC case.
// If x_true > x_false, this function returns X such that:
// - x_false < X < x_true
// - f((x_false, X)) = false
// - f([X, x_true)) = true
// or this return x_true if such an X does not exist.
//
// Also note that 'Point' may be floating-point types: the function will still
// converge when the midpoint can't be distinguished from one of the limits,
@@ -68,7 +76,7 @@ namespace operations_research {
// Note also that even if f() is non-deterministic, i.e. f(X) can sometimes
// return true and sometimes false for the same X, then the binary search will
// still finish, but it's hard to say anything about the returned X.
template <class Point>
template <class Point, bool check_bounds = DEBUG_MODE>
Point BinarySearch(Point x_true, Point x_false, std::function<bool(Point)> f);
// Used by BinarySearch(). This is just (x+y)/2, with some DCHECKs to catch
@@ -207,10 +215,12 @@ Point BinarySearchMidpoint(Point x, Point y) {
return midpoint;
}
template <class Point>
template <class Point, bool check_bounds>
Point BinarySearch(Point x_true, Point x_false, std::function<bool(Point)> f) {
DCHECK(f(x_true)) << x_true;
DCHECK(!f(x_false)) << x_false;
if constexpr (check_bounds) {
CHECK(f(x_true)) << x_true;
CHECK(!f(x_false)) << x_false;
}
int num_iterations = 0;
constexpr int kMaxNumIterations = 1000000;
while (true) {

View File

@@ -175,6 +175,53 @@ TEST(BinarySearchDeathTest, DiesIfEitherBoundaryConditionViolatedInFastbuild) {
"");
}
TEST(BinarySearchDeathTest, DiesIfBoundCheckIsEnabledAndABoundIsViolated) {
// EXPECT_DEATH does not work with 2-parameter templates.
auto bs = [](int x_true, int x_false, auto f) {
return BinarySearch<int, true>(x_true, x_false, f);
};
EXPECT_DEATH(bs(/*x_true=*/0, /*x_false=*/42, [](int x) { return x < 999; }),
"");
EXPECT_DEATH(bs(/*x_true=*/0, /*x_false=*/42, [](int x) { return x < 0; }),
"");
EXPECT_DEATH(bs(/*x_true=*/0, /*x_false=*/42, [](int x) { return x > 20; }),
"");
}
TEST(BinarySearchTest, NoDeathIfBoundCheckIsDisabled) {
// EXPECT_EQ does not work with 2-parameter templates.
auto bs = [](int x_true, int x_false, auto f) {
return BinarySearch<int, false>(x_true, x_false, f);
};
// f is true on the whole interval ]0, 42[: return last value 41.
EXPECT_EQ(bs(/*x_true=*/0, /*x_false=*/42, [](int x) { return x < 999; }),
41);
// f is true on reversed interval ]42, 0[: return last value 1.
EXPECT_EQ(bs(/*x_true=*/42, /*x_false=*/0, [](int x) { return x < 999; }), 1);
// f is false on the whole interval ]0, 42[: return x_true bound 0.
EXPECT_EQ(bs(/*x_true=*/0, /*x_false=*/42, [](int x) { return x < 0; }), 0);
// f is false on reversed interval ]42, 0[: return x_true bound 42.
EXPECT_EQ(bs(/*x_true=*/0, /*x_false=*/42, [](int x) { return x < 0; }), 0);
// f is false on x_true, true on x_false.
// No DCHECK trigger, instead return a transition point of the function
// f': x_true -> true, x_false -> false, x_true < x < x_false -> f(x).
// The transitions are: 0 (true) -> 1 (false) and 41 (true) -> 42 (false).
{
const int x_transition =
bs(/*x_true=*/0, /*x_false=*/42, [](int x) { return x > 20; });
EXPECT_TRUE(x_transition == 0 || x_transition == 41);
}
// f is false on x_true, true on x_false, with a reversed interval.
// No DCHECK trigger, return one of the transition points.
// The transitions are: 42 (true) -> 41 (false) and 1 (true) -> 0 (false).
{
const int x_transition =
bs(/*x_true=*/42, /*x_false=*/0, [](int x) { return x < 20; });
EXPECT_TRUE(x_transition == 42 || x_transition == 1);
}
}
} // namespace
// Examples of cases where one needs to override BinarySearchMidpoint() to get

View File

@@ -19,8 +19,10 @@
#include <random>
#include <vector>
#include "absl/base/log_severity.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/random/random.h"
#include "absl/types/span.h"
#include "gtest/gtest.h"
#include "ortools/base/gmock.h"
#include "ortools/base/stl_util.h"

View File

@@ -20,13 +20,12 @@
#include <random>
#include <vector>
#include "absl/base/macros.h"
#include "absl/container/flat_hash_map.h"
#include "absl/random/distributions.h"
#include "absl/types/span.h"
#include "gtest/gtest.h"
#include "ortools/base/macros.h"
#include "ortools/base/map_util.h"
#include "ortools/base/types.h"
namespace operations_research {
@@ -94,24 +93,24 @@ TEST(LinearAssignmentTest, InvalidMatrix) {
TestMinimization(cost_nan, 0, expected_agents, expected_tasks);
}
#define MATRIX_TEST \
{ \
std::vector<std::vector<double>> cost(kMatrixHeight); \
for (int row = 0; row < kMatrixHeight; ++row) { \
cost[row].resize(kMatrixWidth); \
for (int col = 0; col < kMatrixWidth; ++col) { \
cost[row][col] = kCost[row][col]; \
} \
} \
EXPECT_EQ(arraysize(expected_agents_for_min), \
arraysize(expected_tasks_for_min)); \
EXPECT_EQ(arraysize(expected_agents_for_max), \
arraysize(expected_tasks_for_max)); \
const int assignment_size = arraysize(expected_agents_for_max); \
TestMinimization(cost, assignment_size, expected_agents_for_min, \
expected_tasks_for_min); \
TestMaximization(cost, assignment_size, expected_agents_for_max, \
expected_tasks_for_max); \
#define MATRIX_TEST \
{ \
std::vector<std::vector<double>> cost(kMatrixHeight); \
for (int row = 0; row < kMatrixHeight; ++row) { \
cost[row].resize(kMatrixWidth); \
for (int col = 0; col < kMatrixWidth; ++col) { \
cost[row][col] = kCost[row][col]; \
} \
} \
EXPECT_EQ(ABSL_ARRAYSIZE(expected_agents_for_min), \
ABSL_ARRAYSIZE(expected_tasks_for_min)); \
EXPECT_EQ(ABSL_ARRAYSIZE(expected_agents_for_max), \
ABSL_ARRAYSIZE(expected_tasks_for_max)); \
const int assignment_size = ABSL_ARRAYSIZE(expected_agents_for_max); \
TestMinimization(cost, assignment_size, expected_agents_for_min, \
expected_tasks_for_min); \
TestMaximization(cost, assignment_size, expected_agents_for_max, \
expected_tasks_for_max); \
}
// Test on a 1x1 matrix

View File

@@ -17,8 +17,8 @@
#include <limits>
#include <vector>
#include "absl/base/macros.h"
#include "gtest/gtest.h"
#include "ortools/base/macros.h"
#include "ortools/util/time_limit.h"
namespace operations_research {

View File

@@ -44,7 +44,6 @@ cc_library(
hdrs = [
"commandlineflags.h",
"init_google.h",
"logging.h",
"stl_logging.h",
"types.h",
"version.h",
@@ -63,7 +62,6 @@ cc_library(
deps = [
":commandlineflags",
":logging",
":macros",
":types",
"@com_google_absl//absl/base",
"@com_google_absl//absl/container:flat_hash_map",
@@ -73,7 +71,10 @@ cc_library(
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/flags:usage",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/log:die_if_null",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
@@ -617,7 +618,6 @@ cc_library(
srcs = ["timer.cc"],
hdrs = ["timer.h"],
deps = [
":macros",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/time",
],

View File

@@ -14,6 +14,6 @@
#ifndef OR_TOOLS_BASE_ADJUSTABLE_PRIORITY_QUEUE_INL_H_
#define OR_TOOLS_BASE_ADJUSTABLE_PRIORITY_QUEUE_INL_H_
#include "ortools/base/adjustable_priority_queue.h"
#include "ortools/base/adjustable_priority_queue.h" // IWYU pragma: export
#endif // OR_TOOLS_BASE_ADJUSTABLE_PRIORITY_QUEUE_INL_H_

View File

@@ -20,8 +20,6 @@
#include <list>
#include <vector>
#include "ortools/base/macros.h"
template <typename T, typename Comparator>
class LowerPriorityThan {
public:

View File

@@ -68,7 +68,7 @@ TEST(ConstantDivisorTemplateTest, Simple) {
}
TEST(ConstantDivisorUint64Test, Bugs) {
// If forumula (27) from p231 is ever implemented, these divisors will break
// If formula (27) from p231 is ever implemented, these divisors will break
// if a >= is accidentally used instead of >.
EXPECT_EQ(uint64_t{828560257293048160},
ConstantDivisor<uint64_t>(21).div(uint64_t{17399765403154011380u}));

View File

@@ -28,7 +28,7 @@ enum class AppendedStreams {
kIgnoreAppendedData,
};
// Return a readonly file that contains a uncompressed version of
// Return a read-only file that contains a uncompressed version of
// another File.
//
// If "ownership == TAKE_OWNERSHIP", the file takes ownership of

View File

@@ -147,14 +147,12 @@
#include <stddef.h>
#include <functional>
#include <iosfwd>
#include <ostream> // NOLINT
#include <type_traits>
#include "absl/base/port.h"
#include "absl/base/attributes.h"
#include "absl/strings/string_view.h"
#include "ortools/base/macros.h"
namespace gtl {
@@ -198,8 +196,13 @@ class IntType {
}
};
template <typename H>
friend H AbslHashValue(H h, const IntType& i) {
return H::combine(std::move(h), i.value());
}
public:
// Default c'tor initializing value_ to 0.
// Default constructor initializing value_ to 0.
constexpr IntType() : value_(0) {}
// C'tor explicitly initializing from a ValueType.
constexpr explicit IntType(ValueType value) : value_(value) {}
@@ -273,9 +276,6 @@ class IntType {
private:
// The integer value of type ValueType.
ValueType value_;
COMPILE_ASSERT(std::is_integral<ValueType>::value,
invalid_integer_type_for_id_type_);
} ABSL_ATTRIBUTE_PACKED;
// -- NON-MEMBER STREAM OPERATORS ----------------------------------------------
@@ -357,11 +357,4 @@ INT_TYPE_COMPARISON_OP(>=); // NOLINT
} // namespace gtl
// Allows it to be used as a key to hashable containers.
namespace std {
template <typename IntTypeName, typename ValueType>
struct hash<gtl::IntType<IntTypeName, ValueType> >
: gtl::IntType<IntTypeName, ValueType>::Hasher {};
} // namespace std
#endif // OR_TOOLS_BASE_INT_TYPE_H_

View File

@@ -15,7 +15,6 @@
#include <mutex> // for std::call_once and std::once_flag. // NOLINT
#include "absl/flags/flag.h"
#include "absl/flags/usage.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
@@ -34,6 +33,4 @@ void FixFlagsAndEnvironmentForSwig() {
absl::EnableLogPrefix(false);
}
void KeepAbslSymbols() { absl::SetFlag(&FLAGS_stderrthreshold, 0); }
} // namespace operations_research

View File

@@ -14,9 +14,7 @@
#ifndef OR_TOOLS_BASE_MACROS_H_
#define OR_TOOLS_BASE_MACROS_H_
#include <cstdlib> // for size_t.
#include "ortools/base/base_export.h" // for OR_DLL
#include "ortools/base/base_export.h" // IWYU pragma: export
#define COMPILE_ASSERT(x, msg)
@@ -26,18 +24,4 @@ const bool DEBUG_MODE = false;
const bool DEBUG_MODE = true;
#endif // NDEBUG
// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions.
// It goes in the private: declarations in a class.
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&) = delete; \
TypeName& operator=(const TypeName&) = delete
template <typename T, size_t N>
char (&ArraySizeHelper(T (&array)[N]))[N];
#ifndef COMPILER_MSVC
template <typename T, size_t N>
char (&ArraySizeHelper(const T (&array)[N]))[N];
#endif
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
#endif // OR_TOOLS_BASE_MACROS_H_

View File

@@ -11,12 +11,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "absl/log/check.h"
#if defined(_MSC_VER)
#define _USE_MATH_DEFINES
#include <cmath>
#endif
#include "ortools/base/logging.h"
#include "ortools/base/mathutil.h"
namespace operations_research {

View File

@@ -24,7 +24,6 @@
#include "absl/base/casts.h"
#include "ortools/base/logging.h"
#include "ortools/base/macros.h"
namespace operations_research {
class MathUtil {
@@ -173,12 +172,6 @@ class MathUtil {
// the results are undefined.
template <class IntOut, class FloatIn>
static IntOut SafeCast(FloatIn x) {
COMPILE_ASSERT(!std::numeric_limits<FloatIn>::is_integer,
FloatIn_is_integer);
COMPILE_ASSERT(std::numeric_limits<IntOut>::is_integer,
IntOut_is_not_integer);
COMPILE_ASSERT(std::numeric_limits<IntOut>::radix == 2, IntOut_is_base_2);
// Special case NaN, for which the logic below doesn't work.
if (std::isnan(x)) {
return 0;
@@ -230,11 +223,6 @@ class MathUtil {
// --------------------------------------------------------------------
template <class IntOut, class FloatIn>
static IntOut SafeRound(FloatIn x) {
COMPILE_ASSERT(!std::numeric_limits<FloatIn>::is_integer,
FloatIn_is_integer);
COMPILE_ASSERT(std::numeric_limits<IntOut>::is_integer,
IntOut_is_not_integer);
if (std::isnan(x)) {
return 0;
} else {

View File

@@ -17,10 +17,8 @@
#include <cstdlib>
#include <cstring>
#include "absl/strings/internal/memutil.h"
namespace strings {
char* memdup(const char* s, size_t slen) {
inline char* memdup(const char* s, size_t slen) {
void* copy;
if ((copy = malloc(slen)) == nullptr) return nullptr;
memcpy(copy, s, slen);

View File

@@ -14,6 +14,9 @@
#ifndef OR_TOOLS_BASE_MURMUR_H_
#define OR_TOOLS_BASE_MURMUR_H_
#include <cstddef>
#include <cstdint>
#include "ortools/base/hash.h"
namespace util_hash {

View File

@@ -14,9 +14,8 @@
#ifndef OR_TOOLS_BASE_PARSE_TEST_PROTO_H_
#define OR_TOOLS_BASE_PARSE_TEST_PROTO_H_
#include <memory>
#include <ostream>
#include <string>
#include <string_view>
#include "google/protobuf/message.h"
#include "google/protobuf/text_format.h"
@@ -32,7 +31,7 @@ class ParseProtoHelper {
template <class T>
operator T() { // NOLINT(runtime/explicit)
T result;
const bool ok = ::google::protobuf::TextFormat::TextFormat::ParseFromString(
const bool ok = google::protobuf::TextFormat::TextFormat::ParseFromString(
asciipb_, &result);
EXPECT_TRUE(ok) << "Failed to parse text proto: " << asciipb_;
return result;

View File

@@ -14,9 +14,10 @@
#ifndef OR_TOOLS_BASE_PARSE_TEXT_PROTO_H_
#define OR_TOOLS_BASE_PARSE_TEXT_PROTO_H_
#include <string>
#include <string_view>
#include "absl/log/absl_check.h"
#include "absl/log/check.h"
#include "google/protobuf/message.h"
#include "google/protobuf/text_format.h"
@@ -24,13 +25,13 @@ namespace google::protobuf::contrib::parse_proto {
template <typename T>
bool ParseTextProto(const std::string& input, T* proto) {
return ::google::protobuf::TextFormat::ParseFromString(input, proto);
return google::protobuf::TextFormat::ParseFromString(input, proto);
}
template <typename T>
T ParseTextOrDie(const std::string& input) {
T result;
ABSL_CHECK(ParseTextProto(input, &result));
CHECK(ParseTextProto(input, &result));
return result;
}
@@ -42,7 +43,7 @@ class ParseProtoHelper {
template <class T>
operator T() { // NOLINT(runtime/explicit)
T result;
const bool ok = ::google::protobuf::TextFormat::TextFormat::ParseFromString(
const bool ok = google::protobuf::TextFormat::TextFormat::ParseFromString(
asciipb_, &result);
CHECK(ok) << "Failed to parse text proto: " << asciipb_;
return result;
@@ -54,7 +55,7 @@ class ParseProtoHelper {
} // namespace text_proto_internal
text_proto_internal::ParseProtoHelper ParseTextProtoOrDie(
inline text_proto_internal::ParseProtoHelper ParseTextProtoOrDie(
std::string_view input) {
return text_proto_internal::ParseProtoHelper(input);
}

View File

@@ -27,11 +27,9 @@
//
#include <iterator>
#include <type_traits>
#include "absl/types/span.h"
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/repeated_field.h"
namespace google::protobuf::contrib::utils {
using google::protobuf::GetEnumDescriptor;

View File

@@ -15,15 +15,14 @@
#define OR_TOOLS_BASE_PROTOBUF_UTIL_H_
#include <string>
#include <vector>
#include "absl/log/check.h"
#include "google/protobuf/repeated_field.h"
#include "google/protobuf/repeated_ptr_field.h"
#include "google/protobuf/text_format.h"
#include "ortools/base/logging.h"
namespace google {
namespace protobuf {
namespace util {
namespace google::protobuf::util {
// RepeatedPtrField version.
template <typename T>
inline void Truncate(RepeatedPtrField<T>* array, int new_size) {
@@ -108,8 +107,6 @@ T ParseTextOrDie(const std::string& input) {
return result;
}
} // namespace util
} // namespace protobuf
} // namespace google
} // namespace google::protobuf::util
#endif // OR_TOOLS_BASE_PROTOBUF_UTIL_H_

View File

@@ -14,7 +14,7 @@
#ifndef OR_TOOLS_BASE_RECORDIO_H_
#define OR_TOOLS_BASE_RECORDIO_H_
#include <memory>
#include <cstdint>
#include <string>
#include "ortools/base/file.h"
@@ -35,7 +35,7 @@ class RecordWriter {
// Magic number when reading and writing protocol buffers.
static const int kMagicNumber;
explicit RecordWriter(File* const file);
explicit RecordWriter(File* file);
template <class P>
bool WriteProtocolMessage(const P& proto) {

View File

@@ -19,21 +19,18 @@
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <deque>
#include <forward_list>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>
#include "absl/base/attributes.h"
#include "absl/meta/type_traits.h"
#include "absl/strings/internal/resize_uninitialized.h"
#include "ortools/base/macros.h"
namespace gtl {
namespace internal {

View File

@@ -88,7 +88,7 @@
// The class also defines a hash functor that allows the StrongInt to be used
// as key to hashable containers such as hash_map and hash_set.
//
// We suggest using the StrongIntIndexedContainer wrapper around google3's
// We suggest using the StrongIntIndexedContainer wrapper around
// FixedArray and STL vector (see int-type-indexed-container.h) if an StrongInt
// is intended to be used as an index into these containers. These wrappers are
// indexed in a type-safe manner using StrongInts to ensure type-safety.
@@ -147,15 +147,18 @@
#include <stddef.h>
#include <cstdint>
#include <functional>
#include <iosfwd>
#include <iterator>
#include <limits>
#include <ostream> // NOLINT
#include <type_traits>
#include "absl/base/attributes.h"
#include "absl/base/port.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "ortools/base/macros.h"
namespace util_intops {
@@ -200,8 +203,13 @@ class StrongInt {
}
};
template <typename H>
friend H AbslHashValue(H h, const StrongInt& i) {
return H::combine(std::move(h), i.value());
}
public:
// Default c'tor initializing value_ to 0.
// Default ctor initializing value_ to 0.
constexpr StrongInt() : value_(0) {}
// C'tor explicitly initializing from a ValueType.
constexpr explicit StrongInt(ValueType value) : value_(value) {}
@@ -285,9 +293,6 @@ class StrongInt {
private:
// The integer value of type ValueType.
ValueType value_;
COMPILE_ASSERT(std::is_integral<ValueType>::value,
invalid_integer_type_for_id_type_);
} ABSL_ATTRIBUTE_PACKED;
// -- NON-MEMBER STREAM OPERATORS ----------------------------------------------

View File

@@ -13,6 +13,8 @@
#include "ortools/base/timer.h"
#include "absl/log/check.h"
ScopedWallTime::ScopedWallTime(double* aggregate_time)
: aggregate_time_(aggregate_time), timer_() {
DCHECK(aggregate_time != nullptr);

View File

@@ -16,10 +16,8 @@
#include <cstdint>
#include "absl/log/check.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "ortools/base/macros.h"
class WallTimer {
public:
@@ -83,6 +81,9 @@ typedef CycleTimer SimpleCycleTimer;
// Conversion routines between CycleTimer::GetCycles and actual times.
class CycleTimerBase {
public:
CycleTimerBase(const CycleTimerBase&) = delete;
CycleTimerBase& operator=(const CycleTimerBase&) = delete;
static int64_t SecondsToCycles(double s) {
return static_cast<int64_t>(s * 1e9);
}
@@ -109,7 +110,5 @@ class ScopedWallTime {
// When the instance was created.
WallTimer timer_;
DISALLOW_COPY_AND_ASSIGN(ScopedWallTime);
};
#endif // OR_TOOLS_BASE_TIMER_H_

View File

@@ -34,11 +34,8 @@
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include "ortools/base/logging.h"
namespace operations_research {
namespace gtl {
// Cmp is an stl binary predicate. Note that Cmp is the "greater" predicate,

View File

@@ -14,6 +14,7 @@
#ifndef OR_TOOLS_BASE_TYPEID_H_
#define OR_TOOLS_BASE_TYPEID_H_
#include <cstddef>
namespace gtl {
template <typename T>
inline size_t FastTypeId() {

View File

@@ -712,6 +712,7 @@ static const flex_int32_t yy_rule_can_match_eol[32] = {
#include <cstdint>
#include <string>
#include "absl/log/check.h"
#include "absl/strings/numbers.h"
#include "ortools/flatzinc/parser.tab.hh"
#if defined(_MSC_VER)

View File

@@ -13,6 +13,9 @@
#include "ortools/init/init.h"
#include <string>
#include "absl/base/log_severity.h"
#include "absl/flags/flag.h"
#include "absl/flags/usage.h"
#include "absl/log/globals.h"
@@ -28,7 +31,7 @@ void CppBridge::InitLogging(const std::string& usage) {
}
void CppBridge::SetFlags(const CppFlags& flags) {
absl::SetFlag(&FLAGS_stderrthreshold, flags.stderrthreshold);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::EnableLogPrefix(flags.log_prefix);
if (!flags.cp_model_dump_prefix.empty()) {
absl::SetFlag(&FLAGS_cp_model_dump_prefix, flags.cp_model_dump_prefix);