不同仓库的合并请求带刷新 #16

Closed
jasder wants to merge 30 commits from forgetest1/antlr:12231 into fix-3216
3 changed files with 7 additions and 10 deletions
Showing only changes of commit 4dfacf63e2 - Show all commits

View File

@ -34,7 +34,6 @@
#include <exception>
#include <bitset>
#include <condition_variable>
#include <functional>
#ifndef USE_UTF8_INSTEAD_OF_CODECVT
#include <codecvt>

View File

@ -202,12 +202,6 @@ namespace antlrcpp {
return result;
}
//----------------- FinallyAction ------------------------------------------------------------------------------------
FinalAction finally(std::function<void ()> f) {
return FinalAction(f);
}
//----------------- SingleWriteMultipleRead --------------------------------------------------------------------------
void SingleWriteMultipleReadLock::readLock() {

View File

@ -19,8 +19,9 @@ namespace antlrcpp {
std::string indent(const std::string &s, const std::string &indentation, bool includingFirst = true);
// Using RAII + a lambda to implement a "finally" replacement.
template <typename OnEnd>
struct FinalAction {
FinalAction(std::function<void ()> f) : _cleanUp { f } {}
FinalAction(OnEnd f) : _cleanUp { std::move(f) } {}
FinalAction(FinalAction &&other) :
_cleanUp(std::move(other._cleanUp)), _enabled(other._enabled) {
other._enabled = false; // Don't trigger the lambda after ownership has moved.
@ -29,11 +30,14 @@ namespace antlrcpp {
void disable() { _enabled = false; }
private:
std::function<void ()> _cleanUp;
OnEnd _cleanUp;
bool _enabled {true};
};
ANTLR4CPP_PUBLIC FinalAction finally(std::function<void ()> f);
template <typename OnEnd>
FinalAction<OnEnd> finally(OnEnd f) {
return FinalAction<OnEnd>(std::move(f));
}
// Convenience functions to avoid lengthy dynamic_cast() != nullptr checks in many places.
template <typename T1, typename T2>