DGtal-team / DGtal

Digital Geometry Tools and Algorithm Library
https://dgtal.org
GNU Lesser General Public License v3.0
370 stars 115 forks source link

Build error around iterator traits with clang 3.0° (default clang on ubuntu) #666

Closed alinemartin closed 10 years ago

alinemartin commented 11 years ago

There is a build issue in IteratorCirculatorTraits in the IsCirculator test with clang3.0. It may be related to the trick http://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error

 In file included from /home/pers/aline.martin/projet/DGtal/src/DGtal/io/boards  /Board2D.cpp:30:
 In file included from /home/pers/aline.martin/projet/DGtal/src/DGtal/io/boards/Board2D.h:429:
 In file included from /home/pers/aline.martin/projet/DGtal/src/DGtal/io/Display2DFactory.h:47:
 In file included from /home/pers/aline.martin/projet/DGtal/src/DGtal/geometry/curves/ArithmeticalDSS.h:53:
 In file included from /home/pers/aline.martin/projet/DGtal/src/DGtal/base/ReverseIterator.h:45:
  /home/pers/aline.martin/projet/DGtal/src/DGtal/base/IteratorCirculatorTraits.h:180:55: error: non-type template
  argument of type 'const bool' is not an integral constant expression
   typedef typename detail::IteratorCirculatorTypeImpl<IsCirculator<IC>::value >::Type Type; 
                                                  ^~~~~~~~~~~~~~~~~~~~~~~
  /home/pers/aline.martin/projet/DGtal/src/DGtal   /base/IteratorCirculatorTraits.h:265:20: note: in instantiation
  of template class   'DGtal::IteratorCirculatorType<__gnu_cxx::__normal_iterator<const char *,
  std::basic_string<char> > >' requested here
  typedef typename IteratorCirculatorType<IC>::Type
               ^
  /home/pers/aline.martin/projet/DGtal/src/DGtal/geometry/curves/FreemanChain.h:454:22: note: in instantiation of
  template class    'DGtal::IteratorCirculatorTraits<__gnu_cxx::__normal_iterator<const char *,
  std::basic_string<char> > >' requested here
      typedef typename IteratorCirculatorTraits<ConstIterator>::Value Value; 
                 ^
dcoeurjo commented 11 years ago

@troussil could you please check this issue ?

troussil commented 11 years ago

There is a new boost library in version 1.54 that provides tools to check whether a given type as a given nested type or not: http://www.boost.org/doc/libs/1_54_0/libs/tti/doc/html/index.html

We should use this TTI library in order to avoid this kind of issues: http://www.boost.org/development/int_const_guidelines.html

@dcoeurjo @JacquesOlivierLachaud What is your opinion ?

troussil commented 10 years ago

I finally only used BOOST_STATIC_CONSTANT as mentioned in http://www.boost.org/development/int_const_guidelines.html

Successfully tested with g++ 4.6.3 and clang++ 3.0 on Ubuntu 12.04