From 92f37c3b9fbb80b95949d93d348feb87626b2d98 Mon Sep 17 00:00:00 2001
From: Luc Hermitte <luc.hermitte@c-s.fr>
Date: Tue, 29 May 2012 17:28:42 +0200
Subject: [PATCH] COM: OTB-134/OGR -> Compilation issue under VC2008/Debug

---
 .../OGRAdapters/otbOGRFieldWrapper.cxx         | 12 ++++++------
 .../OGRAdapters/otbOGRFieldWrapper.h           | 13 -------------
 .../OGRAdapters/otbOGRFieldWrapper.txx         | 18 ++++++++----------
 3 files changed, 14 insertions(+), 29 deletions(-)

diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.cxx b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.cxx
index 7cb91c61bc..eee8ee907d 100644
--- a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.cxx
+++ b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.cxx
@@ -66,18 +66,18 @@ BOOST_STATIC_ASSERT(!(boost::is_same<
     >::value
 ));
 
-BOOST_STATIC_ASSERT((boost::is_array<int[42]>::value));
-BOOST_STATIC_ASSERT(!(boost::is_array<boost::array<int, 42> >::value));
-BOOST_STATIC_ASSERT(!(boost::is_array<std::vector<int> >::value));
+BOOST_MPL_ASSERT((boost::is_array<int[42]>));
+BOOST_MPL_ASSERT_NOT((boost::is_array<boost::array<int, 42> >));
+BOOST_MPL_ASSERT_NOT((boost::is_array<std::vector<int> >));
 
 BOOST_STATIC_ASSERT((boost::is_contiguous<int*>::value));
 BOOST_STATIC_ASSERT((boost::is_contiguous<int[42]>::value));
 BOOST_STATIC_ASSERT((boost::is_contiguous<boost::array<int, 42> >::value));
 BOOST_STATIC_ASSERT((boost::is_contiguous<std::vector<int> >::value));
 
-BOOST_STATIC_ASSERT((boost::is_same<int, CppToOGRConverter_trait<int>::type >::value));
-BOOST_STATIC_ASSERT((boost::is_same<char*, CppToOGRConverter_trait<char[8]>::type >::value));
-BOOST_STATIC_ASSERT(!(boost::is_same<char*, char[8] >::value));
+BOOST_MPL_ASSERT((boost::is_same<int, CppToOGRConverter_trait<int>::type >));
+BOOST_MPL_ASSERT((boost::is_same<char*, CppToOGRConverter_trait<char[8]>::type >));
+BOOST_MPL_ASSERT_NOT((boost::is_same<char*, char[8] >));
 
 }
 } } // end namespace otb::ogr
diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.h b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.h
index ba0f1bd519..c80bce4d7a 100644
--- a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.h
+++ b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.h
@@ -119,19 +119,6 @@ public:
    */
   template <typename T> void SetValue(T const& value);
 
-  /**
-   * Value setter.
-   * This overload is meant to help type promotions from <tt>char const[42]</tt> to
-   * <tt>char const*</tt>.
-   * \param[in] value  New value for the field.
-   * \throw None
-   * \pre \c value's kind must match the field's type.
-   * \internal
-   * This function automagically decodes the type of the parameter in order to
-   * use the ad'hoc setter from \c OGRFeature.
-   */
-  template <typename T, size_t N> void SetValue(T const value[N]);
-
   /**
    * Value getter.
    * \tparam T expected type for the stored value.
diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.txx b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.txx
index 3091d312c1..75c73fbb94 100644
--- a/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.txx
+++ b/Code/UtilitiesAdapters/OGRAdapters/otbOGRFieldWrapper.txx
@@ -30,6 +30,8 @@
 #include <boost/mpl/pair.hpp>
 #include <boost/mpl/int.hpp>
 #include <boost/mpl/at.hpp>
+#include <boost/mpl/assert.hpp>
+// #include <boost/mpl/print.hpp>
 
 #include <boost/static_assert.hpp>
 #include <boost/range/size.hpp>
@@ -72,6 +74,7 @@ typedef boost::mpl::map
   , pair<std::vector<double>     , int_<OFTRealList> >
   , pair<std::string             , int_<OFTString> >
   , pair<char*                   , int_<OFTString> >
+  , pair<char const*             , int_<OFTString> >
   , pair<std::vector<std::string>, int_<OFTStringList> >
   // OFTBinary
   // OFTDate
@@ -383,25 +386,20 @@ void otb::ogr::Field::SetValue(T const& value)
   CheckInvariants();
   typedef internal::CppToOGRConverter_trait<T> Converter;
   typedef typename Converter::type             InterfaceType;
-  // BOOST_STATIC_ASSERT(!(boost::is_array<InterfaceType>::value));
+  // uncomment the next line to debug the InterfaceType computed
+  // boost::mpl::print<typename internal::CppToOGRConverter_trait<T>::type> interface_type; (void) interface_type;
+  BOOST_MPL_ASSERT_MSG(!boost::is_array<InterfaceType>::value, InterFaceType_Cant_Be_An_array, (T, InterfaceType));
   typedef typename boost::mpl::at<internal::FieldType_Map, InterfaceType>::type Kind;
+  BOOST_MPL_ASSERT_MSG(!(boost::is_same<Kind, boost::mpl::void_>::value), UNEXPECTED_KIND_TYPE, (T, InterfaceType, Kind));
   const int VALUE = Kind::value;
-  BOOST_STATIC_ASSERT(!(boost::is_same<Kind, boost::mpl::void_>::value));
   assert(m_Definition.GetType() == VALUE && "OGR field type mismatches the type of new field value");
   typedef typename boost::mpl::at<internal::FieldSetters_Map, Kind>::type SetterType;
   // If you experience a static assertion failure in the line below, it means
   // the type of the parameter is not supported to set a field.
-  BOOST_STATIC_ASSERT(!(boost::is_same<SetterType, boost::mpl::void_>::value));
+  BOOST_MPL_ASSERT_NOT((boost::is_same<SetterType, boost::mpl::void_>));
   SetterType::call(*m_Feature, m_index, Converter::convert(value));
 }
 
-template <typename T, size_t N>
-inline
-void otb::ogr::Field::SetValue(T const value[N])
-{
-  this->SetValue(&value[0]);
-}
-
 template <typename T>
 inline
 T otb::ogr::Field::GetValue() const
-- 
GitLab