Skip to content
Browse files

test: GCC 4.7 expects the definition of value_diff up front

It won't look lower in the file. However I think that is expected
operation for all compilers. How did this work previously?
  • Loading branch information...
1 parent a3cfc07 commit d8c053ddb109c81859d3cc4ef29eb05c9d15a057 Zack Moratto committed Nov 16, 2012
Showing with 30 additions and 30 deletions.
  1. +30 −30 src/test/Helpers.h
View
60 src/test/Helpers.h
@@ -84,6 +84,36 @@ ::std::string format(const T& x) {
return PrintToString(_numeric(x));
}
+// Value diffs
+template <typename ElemT, typename Elem2T>
+double value_diff(const vw::PixelMathBase<ElemT>& a, const vw::PixelMathBase<Elem2T>& b) {
+ BOOST_STATIC_ASSERT((boost::is_same<ElemT, Elem2T>::value));
+ typedef typename CompoundChannelType<ElemT>::type channel_type;
+ double acc = 0.0;
+ for( size_t c=0; c < PixelNumChannels<ElemT>::value; ++c ) {
+ channel_type const& a_x = compound_select_channel<channel_type const&>(a.impl(),c);
+ channel_type const& b_x = compound_select_channel<channel_type const&>(b.impl(),c);
+ double diff = double(a_x) - double(b_x);
+ acc += diff*diff;
+ }
+ return ::sqrt(acc);
+}
+
+template <typename T1, typename T2>
+double value_diff(const std::complex<T1>& a, const std::complex<T2>& b) {
+ return std::abs(std::complex<double>(a) - std::complex<double>(b));
+}
+
+template <typename T1, typename T2>
+struct both_are_arithmetic : boost::mpl::and_<boost::is_arithmetic<T1>, boost::is_arithmetic<T2> > {};
+
+template <typename T1, typename T2>
+typename boost::enable_if<both_are_arithmetic<T1,T2>, double>::type
+value_diff(const T1& a, const T2& b) {
+ BOOST_STATIC_ASSERT(boost::is_arithmetic<T1>::value);
+ BOOST_STATIC_ASSERT(boost::is_arithmetic<T2>::value);
+ return ::fabs(double(a) - double(b));
+}
// A version of std::mismatch that returns the set of differences rather than
// just the first
@@ -427,36 +457,6 @@ _CheckNDRange<CmpT> check_nd_range(const CmpT& cmp) {
#define EXPECT_MATRIX_NEAR(e, a, delta) EXPECT_SEQ_NEAR(e,a,delta)
#define ASSERT_MATRIX_NEAR(e, a, delta) ASSERT_SEQ_NEAR(e,a,delta)
-template <typename ElemT, typename Elem2T>
-double value_diff(const vw::PixelMathBase<ElemT>& a, const vw::PixelMathBase<Elem2T>& b) {
- BOOST_STATIC_ASSERT((boost::is_same<ElemT, Elem2T>::value));
- typedef typename CompoundChannelType<ElemT>::type channel_type;
- double acc = 0.0;
- for( size_t c=0; c < PixelNumChannels<ElemT>::value; ++c ) {
- channel_type const& a_x = compound_select_channel<channel_type const&>(a.impl(),c);
- channel_type const& b_x = compound_select_channel<channel_type const&>(b.impl(),c);
- double diff = double(a_x) - double(b_x);
- acc += diff*diff;
- }
- return ::sqrt(acc);
-}
-
-template <typename T1, typename T2>
-double value_diff(const std::complex<T1>& a, const std::complex<T2>& b) {
- return std::abs(std::complex<double>(a) - std::complex<double>(b));
-}
-
-template <typename T1, typename T2>
-struct both_are_arithmetic : boost::mpl::and_<boost::is_arithmetic<T1>, boost::is_arithmetic<T2> > {};
-
-template <typename T1, typename T2>
-typename boost::enable_if<both_are_arithmetic<T1,T2>, double>::type
-value_diff(const T1& a, const T2& b) {
- BOOST_STATIC_ASSERT(boost::is_arithmetic<T1>::value);
- BOOST_STATIC_ASSERT(boost::is_arithmetic<T2>::value);
- return ::fabs(double(a) - double(b));
-}
-
}} // namespace t
#endif

0 comments on commit d8c053d

Please sign in to comment.
Something went wrong with that request. Please try again.