From a06f260f426d5b8315d44b893427229834bc4d16 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 12 Jun 2023 21:46:32 -0400 Subject: [PATCH] Fix C++11 compiler error with C++14 rbegin --- include/verilated_types.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/verilated_types.h b/include/verilated_types.h index 46a4d99b5..cbd05ad96 100644 --- a/include/verilated_types.h +++ b/include/verilated_types.h @@ -1085,14 +1085,18 @@ public: return with_func(0, a) < with_func(0, b); }); } - void rsort() { std::sort(std::rbegin(m_storage), std::rend(m_storage)); } + // std::rbegin/std::rend not available until C++14 + void rsort() { + std::sort(std::begin(m_storage), std::end(m_storage), std::greater()); + } template void rsort(Func with_func) { // with_func returns arbitrary type to use for the sort comparison - std::sort(std::rbegin(m_storage), std::rend(m_storage), + // std::rbegin/std::rend not available until C++14, so using > below + std::sort(std::begin(m_storage), std::end(m_storage), [=](const T_Value& a, const T_Value& b) { // index number is meaningless with sort, as it changes - return with_func(0, a) < with_func(0, b); + return with_func(0, a) > with_func(0, b); }); } void reverse() { std::reverse(std::begin(m_storage), std::end(m_storage)); }