<div>I am trying to ensure the type that my function is instantiated with has a certainly property. I tried this:</div><div><br></div><div>#include <itkConceptChecking.h></div><div>#include <itkImage.h></div><div>
#include <itkVectorImage.h></div><div><br></div><div>template <typename T></div><div>void MyFunction(const T& image)</div><div>{</div><div> // MyFunction should only accept types that have an operator[]</div>
<div> itkConceptMacro( nameOfCheck, ( itk::Concept::BracketOperator< T> ) ); // here, 'nameOfCheck can be anything, right?</div><div><br></div><div>}</div><div><br></div><div>int main(int, char*[])</div><div>{</div>
<div> itk::VariableLengthVector<float> a;</div><div> a[0] = 1;</div><div> MyFunction(a);</div><div><br></div><div> int b;</div><div>// MyFunction(b);</div><div><br></div><div> return EXIT_SUCCESS;</div><div>}</div>
<div><br></div><div>-----------</div><div><br></div><div>VariableLengthVector definitely has operator[], as shown with the assignment a[0] = 1. However, the call to MyFunction(a) produces compiler errors that say "no match for operator[]". Can anyone explain what I'm doing wrong here?</div>
<div><br></div>Thanks,<br><br>David<br>