Disallow same option being added twice

Now exits during startup.

```
./stockfish
Stockfish dev-20250202-243c7c6a by the Stockfish developers (see AUTHORS file)
x1,5,0,10,0.5,0.0020
Option: "x1" was already added!
```

i.e. prevents and helps debug this case

```cpp
int x1 = 5;

TUNE(x1);
TUNE(x1);
```

closes https://github.com/official-stockfish/Stockfish/pull/5847

No functional change
This commit is contained in:
Disservin
2025-02-02 18:05:16 +01:00
parent 8c73472ac8
commit c12dbdedd9
4 changed files with 100 additions and 71 deletions
+5 -3
View File
@@ -54,12 +54,13 @@ class Option {
friend std::ostream& operator<<(std::ostream&, const OptionsMap&);
int operator<<(const Option&) = delete;
private:
friend class OptionsMap;
friend class Engine;
friend class Tune;
void operator<<(const Option&);
std::string defaultValue, currentValue, type;
int min, max;
@@ -82,8 +83,9 @@ class OptionsMap {
void setoption(std::istringstream&);
Option operator[](const std::string&) const;
Option& operator[](const std::string&);
const Option& operator[](const std::string&) const;
void add(const std::string&, const Option& option);
std::size_t count(const std::string&) const;