示例#1
0
void check_bind0(Binder b, R r)
{
   BOOST_STATIC_ASSERT(::std::tr1::is_bind_expression<Binder>::value);
   verify_return_type(b(), r);

   typedef typename Binder::result_type result_type;
   BOOST_STATIC_ASSERT((::boost::is_same<result_type, R>::value));
}
示例#2
0
int main()
{
   std::tr1::tuple<int> t1a;
   std::tr1::tuple<int> t1b(0);
   std::tr1::tuple<int> t1c(t1b);
   t1a = t1c;
   std::tr1::tuple<int> t1d(std::tr1::tuple<short>(0));
   t1a = std::tr1::tuple<short>(0);

   std::tr1::tuple<int, long> t2a;
   std::tr1::tuple<int, long> t2b(0, 0);
   std::tr1::tuple<int, long> t2c(t2b);
   t2a = t2c;
   std::tr1::tuple<int, long> t2d(std::tr1::tuple<short, int>(0, 0));
   t2a = std::tr1::tuple<short, int>(0, 0);
   //std::tr1::tuple<int, long> t2e(std::make_pair(0, 0L));
   //t2e = std::make_pair(0, 0L);
  
   // check implementation limits:
   std::tr1::tuple<int, long, float, int, int, int, int, int, int> t10(0, 0, 0, 0, 0, 0, 0, 0, 0);

   // make_tuple:
   verify_return_type(std::tr1::make_tuple(0, 0, 0L), std::tr1::tuple<int, int, long>());
   int i = 0;
   std::tr1::tuple<int&, int, long> t3a(std::tr1::make_tuple(std::tr1::ref(i), 0, 0L));
   verify_return_type(std::tr1::make_tuple(std::tr1::ref(i), 0, 0L), t3a);
   std::tr1::tuple<const int&, int, long> t3b(std::tr1::make_tuple(std::tr1::cref(i), 0, 0L));
   verify_return_type(std::tr1::make_tuple(std::tr1::cref(i), 0, 0L), t3b);
   long j = 0;
   std::tr1::tuple<int&, long&> tt(std::tr1::tie(i,j));

   BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::tr1::tuple<int, long> >::value == 2));
   BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::tr1::tuple<int, long, float, int, int, int, int, int, int> >::value == 9));

   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple<int, long> >::type, int>::value));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<1, std::tr1::tuple<int, long> >::type, long>::value));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple<int&, long> >::type, int&>::value));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple<const int&, long> >::type, const int&>::value));

   // get:
   verify_return_type(&::std::tr1::get<0>(t1a), static_cast<int*>(0));
   verify_return_type(&::std::tr1::get<1>(t2d), static_cast<long*>(0));
   verify_return_type(&::std::tr1::get<0>(t3a), static_cast<int*>(0));
   verify_return_type(&::std::tr1::get<0>(t3b), static_cast<const int*>(0));
   const std::tr1::tuple<int>& cr1 = t1a;
   verify_return_type(&::std::tr1::get<0>(cr1), static_cast<const int*>(0));
   const std::tr1::tuple<int&, int, long>& cr2 = t3a;
   verify_return_type(&::std::tr1::get<0>(cr2), static_cast<int*>(0));
   const std::tr1::tuple<const int&, int, long>& cr3 = t3b;
   // comparison:
   verify_return_type(cr2 == cr3, false);
   verify_return_type(cr2 != cr3, false);
   verify_return_type(cr2 < cr3, false);
   verify_return_type(cr2 > cr3, false);
   verify_return_type(cr2 <= cr3, false);
   verify_return_type(cr2 >= cr3, false);

   // pair interface:
   BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::pair<int, long> >::value == 2));
   BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::pair<int, float> >::value == 2));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::pair<int, long> >::type, int>::value));
   BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<1, std::pair<int, long> >::type, long>::value));

   std::pair<int, long> p1;
   const std::pair<int, long>& p2 = p1;
   verify_return_type(&std::tr1::get<0>(p1), static_cast<int*>(0));
   verify_return_type(&std::tr1::get<1>(p1), static_cast<long*>(0));
   verify_return_type(&std::tr1::get<0>(p2), static_cast<const int*>(0));
   verify_return_type(&std::tr1::get<1>(p2), static_cast<const long*>(0));

   return 0;
}
示例#3
0
void check_array(T& a)
{
    typedef typename T::reference reference;
    typedef typename T::const_reference const_reference;
    typedef typename T::iterator iterator;
    typedef typename T::const_iterator const_iterator;
    typedef typename T::size_type size_type;
    typedef typename T::difference_type difference_type;
    typedef typename T::value_type value_type;
    typedef typename T::reverse_iterator reverse_iterator;
    typedef typename T::const_reverse_iterator const_reverse_iterator;

    BOOST_STATIC_ASSERT((::boost::is_same<value_type&, reference>::value));
    BOOST_STATIC_ASSERT((::boost::is_same<value_type const&, const_reference>::value));
    BOOST_STATIC_ASSERT((::boost::is_same<std::size_t, size_type>::value));
    BOOST_STATIC_ASSERT((::boost::is_same<std::ptrdiff_t, difference_type>::value));
    BOOST_STATIC_ASSERT((::boost::is_same<std::reverse_iterator<iterator>, reverse_iterator>::value));
    BOOST_STATIC_ASSERT((::boost::is_same<std::reverse_iterator<const_iterator>, const_reverse_iterator>::value));

    const T& ca = a;
    const T& ca2 = a;
    verify_return_type(a.begin(), iterator());
    verify_return_type(ca.begin(), const_iterator());
    verify_return_type(a.end(), iterator());
    verify_return_type(ca.end(), const_iterator());
    verify_return_type(a.rbegin(), reverse_iterator());
    verify_return_type(ca.rbegin(), const_reverse_iterator());
    verify_return_type(a.rend(), reverse_iterator());
    verify_return_type(ca.rend(), const_reverse_iterator());

    verify_return_type(ca.size(), size_type(0));
    verify_return_type(ca.max_size(), size_type(0));
    verify_return_type(ca.empty(), false);

    verify_return_type(&a[0], static_cast<value_type*>(0));
    verify_return_type(&ca[0], static_cast<const value_type*>(0));
    verify_return_type(&a.at(0), static_cast<value_type*>(0));
    verify_return_type(&ca.at(0), static_cast<const value_type*>(0));
    verify_return_type(&a.front(), static_cast<value_type*>(0));
    verify_return_type(&ca.front(), static_cast<const value_type*>(0));
    verify_return_type(&a.back(), static_cast<value_type*>(0));
    verify_return_type(&ca.back(), static_cast<const value_type*>(0));
    //verify_return_type(a.data(), static_cast<value_type*>(0));
    verify_return_type(ca.data(), static_cast<const value_type*>(0));

    // swap:
    std::tr1::swap(a, a);
    verify_return_type(ca == ca2, false);
    verify_return_type(ca != ca2, false);
    verify_return_type(ca < ca2, false);
    verify_return_type(ca > ca2, false);
    verify_return_type(ca <= ca2, false);
    verify_return_type(ca >= ca2, false);

    BOOST_STATIC_ASSERT((::boost::is_same< typename std::tr1::tuple_element<0,T>::type, value_type>::value));
    verify_return_type(&std::tr1::get<0>(a), static_cast<value_type*>(0));
    verify_return_type(&std::tr1::get<0>(ca), static_cast<const value_type*>(0));
}
示例#4
0
void check_bind1(Binder b, R r, A1 a1)
{
   BOOST_STATIC_ASSERT(::std::tr1::is_bind_expression<Binder>::value);
   verify_return_type(b(a1), r);
}
示例#5
0
int main()
{
   verify_return_type(std::arg(0), double(0));
   verify_return_type(std::arg(0.0), double(0));
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::arg(0.0L), (long double)(0));
#endif
   verify_return_type(std::arg(0.0F), float(0));
   verify_return_type(std::norm(0), double(0));
   verify_return_type(std::norm(0.0), double(0));
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::norm(0.0L), (long double)(0));
#endif
   verify_return_type(std::norm(0.0F), float(0));
   verify_return_type(std::conj(0), std::complex<double>(0));
   verify_return_type(std::conj(0.0), std::complex<double>(0));
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::conj(0.0L), std::complex<long double>(0));
#endif
   verify_return_type(std::conj(0.0F), std::complex<float>(0));
   verify_return_type(std::imag(0), double(0));
   verify_return_type(std::imag(0.0), double(0));
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::imag(0.0L), (long double)(0));
#endif
   verify_return_type(std::imag(0.0F), float(0));
   verify_return_type(std::real(0), double(0));
   verify_return_type(std::real(0.0), double(0));
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::real(0.0L), (long double)(0));
#endif
   verify_return_type(std::real(0.0F), float(0));
   verify_return_type(std::polar(0), std::complex<double>(0));
   verify_return_type(std::polar(0.0), std::complex<double>(0));
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::polar(0.0L), std::complex<long double>(0));
#endif
   verify_return_type(std::polar(0.0F), std::complex<float>(0));
   verify_return_type(std::polar(0, 0L), std::complex<double>(0));
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::polar(0.0, 0.0L), std::complex<long double>(0));
   verify_return_type(std::polar(0.0L, 0.0F), std::complex<long double>(0));
#endif
   verify_return_type(std::polar(0.0F, 0), std::complex<double>(0));

   std::complex<float> f;
   std::complex<double> d;
   std::complex<long double> l;
   float sf;
   double sd;
   long double sl;

   verify_return_type(std::pow(f, f), f);
   verify_return_type(std::pow(f, d), d);
   verify_return_type(std::pow(d, f), d);
   verify_return_type(std::pow(f, l), l);
   verify_return_type(std::pow(l, f), l);
   verify_return_type(std::pow(d, l), l);
   verify_return_type(std::pow(l, d), l);

   verify_return_type(std::pow(f, sf), f);
   verify_return_type(std::pow(f, sd), d);
   verify_return_type(std::pow(d, sf), d);
   verify_return_type(std::pow(f, sl), l);
   verify_return_type(std::pow(l, sf), l);
   verify_return_type(std::pow(d, sl), l);
   verify_return_type(std::pow(l, sd), l);
   verify_return_type(std::pow(f, 0), f);
   verify_return_type(std::pow(d, 0), d);
   verify_return_type(std::pow(l, 0), l);
   verify_return_type(std::pow(f, 0L), d);
   verify_return_type(std::pow(d, 0L), d);
   verify_return_type(std::pow(l, 0L), l);

   verify_return_type(std::pow(sf, f), f);
   verify_return_type(std::pow(sf, d), d);
   verify_return_type(std::pow(sd, f), d);
   verify_return_type(std::pow(sf, l), l);
   verify_return_type(std::pow(sl, f), l);
   verify_return_type(std::pow(sd, l), l);
   verify_return_type(std::pow(sl, d), l);
   verify_return_type(std::pow(2, f), d);
   verify_return_type(std::pow(2, d), d);
   verify_return_type(std::pow(2, l), l);
   verify_return_type(std::pow(2L, f), d);
   verify_return_type(std::pow(2L, d), d);
   verify_return_type(std::pow(2L, l), l);

   verify_return_type(std::tr1::acos(f), f);
   verify_return_type(std::tr1::acos(d), d);
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::tr1::acos(l), l);
#endif
   verify_return_type(std::tr1::asin(f), f);
   verify_return_type(std::tr1::asin(d), d);
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::tr1::asin(l), l);
#endif
   verify_return_type(std::tr1::atan(f), f);
   verify_return_type(std::tr1::atan(d), d);
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::tr1::atan(l), l);
#endif
   verify_return_type(std::tr1::asinh(f), f);
   verify_return_type(std::tr1::asinh(d), d);
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::tr1::asinh(l), l);
#endif
   verify_return_type(std::tr1::acosh(f), f);
   verify_return_type(std::tr1::acosh(d), d);
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::tr1::acosh(l), l);
#endif
   verify_return_type(std::tr1::atanh(f), f);
   verify_return_type(std::tr1::atanh(d), d);
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::tr1::atanh(l), l);
#endif

   //
   // There is a bug in the TR text here, that means we can't always
   // check these as we'd like:
   //
#if !(defined(__GNUC__) && defined(BOOST_HAS_TR1_COMPLEX_INVERSE_TRIG) && !defined(_GLIBCXX_INCLUDE_AS_CXX0X))
   verify_return_type(std::tr1::fabs(f), sf);
   verify_return_type(std::tr1::fabs(d), sd);
#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
   verify_return_type(std::tr1::fabs(l), sl);
#endif
#endif
   return 0;
}