@@ -257,6 +257,29 @@ void TargetSetting::reset()
257257 value.swap (v);
258258}
259259
260+ void TargetSetting::use ()
261+ {
262+ if (use_count > 0 )
263+ use_count--;
264+ if (use_count == 0 )
265+ reset ();
266+ }
267+
268+ void TargetSetting::setUseCount (int c)
269+ {
270+ use_count = c;
271+ }
272+
273+ void TargetSetting::setRequired (bool b)
274+ {
275+ required = b;
276+ }
277+
278+ bool TargetSetting::isRequired () const
279+ {
280+ return required;
281+ }
282+
260283TargetSetting::operator bool () const
261284{
262285 return value.index () != 0 ;
@@ -362,8 +385,30 @@ int TargetSettings::compareEqualKeys(const TargetSettings &lhs, const TargetSett
362385 const auto &other = lhs.settings .size () >= rhs.settings .size () ? lhs : rhs;
363386 bool r = std::all_of (main.settings .begin (), main.settings .end (), [&other](const auto &p)
364387 {
365- if (other[p.first ] && p.second )
388+ if (
389+ // compare if both is present
390+ (other[p.first ] && p.second )
391+
392+ // or one is present and required
393+ || (other[p.first ] && other[p.first ].isRequired ())
394+ || (p.second && p.second .isRequired ())
395+ )
396+ {
366397 return TargetSetting::compareEqualKeys (other[p.first ], p.second ) == 0 ;
398+ }
399+ return true ;
400+ });
401+ // check required settings in other
402+ r &= std::all_of (other.settings .begin (), other.settings .end (), [&main](const auto &p)
403+ {
404+ if (
405+ // compare if any is required
406+ (p.second && p.second .isRequired ()) ||
407+ (main[p.first ] && main[p.first ].isRequired ())
408+ )
409+ {
410+ return TargetSetting::compareEqualKeys (main[p.first ], p.second ) == 0 ;
411+ }
367412 return true ;
368413 });
369414 if (r)
0 commit comments