Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>CAVEAT:</strong> I don't have a compiler in front of me right now, and I'm suddenly unsure about the SFINAE part (not sure whether it applies to the function body, or only to the parameter types). Somebody please correct this if it's wrong.</p> <p>In C++, you could take advantage of the similar syntax of the different classes to create a single function template:</p> <pre><code>template &lt;class ToType, class FromType&gt; ToType ConvertPoint(const FromType&amp; FromValue) { ToType ToValue; ToValue[0] = FromValue[0]; ToValue[1] = FromValue[1]; ToValue[2] = FromValue[2]; return ToValue; } // If the version above failed, the compiler will try this one. // This is called SFINAE template &lt;class ToType, class FromType&gt; ToType ConvertPoint(const FromType&amp; FromValue) { ToType ToValue; ToValue[0] = FromValue.Get(0); ToValue[1] = FromValue.Get(1); ToValue[2] = FromValue.Get(2); return ToValue; } // Usage: KdTree::HyperPoint hyperPoint; FixedPointType fixedPoint = ConvertPoint&lt;FixedPointType&gt;(hyperPoint); </code></pre> <p>I guess you can do the same in C#, although I'm less familiar with the syntax.</p> <p>For the cases where your classes don't exactly follow the same syntax convention, SFINAE helps you by letting you provide several variants - if one fails, the compiler will pick the next one and try with that. Using <a href="http://en.wikipedia.org/wiki/Shim_%28computing%29" rel="nofollow noreferrer">shims</a>, you can limit the number of variants by providing one generic function that uses appropriately defined shims to both set and get each coordinates for all existing classes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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