[Insight-users] Concept checking

David Doria daviddoria at gmail.com
Wed Jan 4 15:07:13 EST 2012


I am trying to ensure the type that my function is instantiated with has a
certainly property. I tried this:

#include <itkConceptChecking.h>
#include <itkImage.h>
#include <itkVectorImage.h>

template <typename T>
void MyFunction(const T& image)
{
  // MyFunction should only accept types that have an operator[]
  itkConceptMacro( nameOfCheck, ( itk::Concept::BracketOperator< T> ) ); //
here, 'nameOfCheck can be anything, right?

}

int main(int, char*[])
{
  itk::VariableLengthVector<float> a;
  a[0] = 1;
  MyFunction(a);

  int b;
//   MyFunction(b);

  return EXIT_SUCCESS;
}

-----------

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?

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120104/9ce0b992/attachment.htm>


More information about the Insight-users mailing list