Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Going deeper in my problem I read two articles providing tracks for a solution:</p> <ul> <li><strong>Kostadin Damevski</strong>, <em>Expressing Measurements Units in Interfaces for Scientific Component Software</em>;</li> <li><strong>Lingxiao Jiang</strong>, <em>A Practical Type System for Validating Dimensional Units Correctness of C Programs</em>.</li> </ul> <p>The first gives good ideas for the interface implementation. The second gives a complete overview of what you must cope with.</p> <p>I keep in mind that <code>boost::units</code> is a complete and efficient way for dimension consistency at compile-time without overhead at runtime. Anyway, for runtime dimension consistency involving dimensions changes you do need a dynamic structure that <code>boost::units</code> does not provide. So here am I: designing a units class that will exactly fit my needs. More work to achieve, more satisfaction at the end...</p> <p>About the original questions:</p> <ul> <li><code>boost::variant</code> works well (it provides the dynamic <code>boost::units</code> is missing) for this job. And furthermore, it can be serialized out of the box. Thus it is a effective approach. But it is adding a layer of abstraction for a simple - I am not saying trivial - task that could be done by a single class.</li> <li>Casting is achieved by <code>boost::variant_cast&lt;&gt;</code> instead of <code>dynamic_cast&lt;&gt;</code>.</li> <li><code>boost::any</code> could be easier to implement but serialization becomes an hard way. </li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload