<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Design on Matt Bolitho</title><link>https://mattbolitho.github.io/tags/design/</link><description>Recent content in Design on Matt Bolitho</description><generator>Hugo -- gohugo.io</generator><language>en-GB</language><copyright>Matt Bolitho</copyright><lastBuildDate>Sun, 08 Sep 2024 19:00:00 +0000</lastBuildDate><atom:link href="https://mattbolitho.github.io/tags/design/index.xml" rel="self" type="application/rss+xml"/><item><title>Structured Validation Rules in C++</title><link>https://mattbolitho.github.io/posts/structured-validation-rules-in-cpp/</link><pubDate>Sun, 08 Sep 2024 19:00:00 +0000</pubDate><guid>https://mattbolitho.github.io/posts/structured-validation-rules-in-cpp/</guid><description>Validation is a common problem when dealing with any data provided by a user. Even when developing a library, you likely provide custom data types for consuming developers, which are equally (if not more!) untrustworthy.
In a personal project, I was dealing with validating user provided numerical optimization problems. For the sake of brevity in this post, let&amp;rsquo;s assume these problems look like this:
1struct OptimizationProblem 2{ 3 std::vector&amp;lt;double&amp;gt; XLb; 4 std::vector&amp;lt;double&amp;gt; XUb; 5 std::function&amp;lt;double(std::span&amp;lt;double const&amp;gt;)&amp;gt; Eval; 6}; OptimizationProblem contains upper and lower bounds for the primal variables we are optimizing over.</description></item></channel></rss>