File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,31 @@ class InFlightSubstitution {
55
55
conformedProtocol);
56
56
}
57
57
58
+ class OptionsAdjustmentScope {
59
+ InFlightSubstitution &IFS;
60
+ SubstOptions SavedOptions;
61
+
62
+ public:
63
+ OptionsAdjustmentScope (InFlightSubstitution &IFS, SubstOptions newOptions)
64
+ : IFS(IFS), SavedOptions(IFS.Options) {
65
+ IFS.Options = newOptions;
66
+ }
67
+
68
+ OptionsAdjustmentScope (const OptionsAdjustmentScope &) = delete ;
69
+ OptionsAdjustmentScope &operator =(const OptionsAdjustmentScope &) = delete ;
70
+
71
+ ~OptionsAdjustmentScope () {
72
+ IFS.Options = SavedOptions;
73
+ }
74
+ };
75
+
76
+ template <class Fn >
77
+ auto withNewOptions (SubstOptions options, Fn &&fn)
78
+ -> decltype(std::forward<Fn>(fn)()) {
79
+ OptionsAdjustmentScope scope (*this , options);
80
+ return std::forward<Fn>(fn)();
81
+ }
82
+
58
83
SubstOptions getOptions () const {
59
84
return Options;
60
85
}
You can’t perform that action at this time.
0 commit comments