 <p>I recommend a lambda (like <a href="http://stackoverflow.com/users/1885037/kaveish">kaveish's</a> <a href="http://stackoverflow.com/a/26770618/309334">answer</a>). But you can have it return a function that checks the appropriate bounds to make everything more readable.</p> <pre><code>auto in = [](int min, int max, char const * const opt_name){ return [opt_name, min, max](unsigned short v){ if(v &lt; min || v &gt; max){ throw opt::validation_error (opt::validation_error::invalid_option_value, opt_name, std::to_string(v)); } }; }; opt::value&lt;unsigned short&gt;()-&gt;default_value(5) -&gt;notifier(in(0, 10, "my_opt")); </code></pre>