示例#1
0
文件: output.c 项目: rhash/RHash
static void setup_log_stream(FILE **p_stream, const opt_tchar* stream_path)
{
	if (stream_path && !(*p_stream = rsh_tfopen(stream_path, RSH_T("w"))) ) {
		log_file_error(t2c(stream_path));
		rsh_exit(2);
	}
}
示例#2
0
void
test_constructors()
{
    cout << "test_constructors" << endl;

    sc_time t1;
    cout << t1 << endl;

    sc_time t2a( 0, SC_SEC );
    cout << t2a << endl;

    sc_time t2b( 1.2345, SC_NS );
    cout << t2b << endl;
    sc_time t2c( 1.2341, SC_NS );
    cout << t2c << endl;

    sc_time t2d( 1, SC_FS );
    cout << t2d << endl;

    sc_time t2e( -1.2345, SC_NS );
    cout << t2e << endl;
    sc_time t2f( -1.2341, SC_NS );
    cout << t2f << endl;

    char v1 = 1;
    signed char v2 = 2;
    unsigned char v3 = 3;
    short v4 = 4;
    unsigned short v5 = 5;
    int v6 = 6;
    unsigned int v7 = 7;
    long v8 = 8;
    unsigned long v9 = 9;
    float v10 = 10;
    double v11 = 11;

    sc_time t2g( v1, SC_NS );
    cout << t2g << endl;
    sc_time t2h( v2, SC_NS );
    cout << t2h << endl;
    sc_time t2i( v3, SC_NS );
    cout << t2i << endl;
    sc_time t2j( v4, SC_NS );
    cout << t2j << endl;
    sc_time t2k( v5, SC_NS );
    cout << t2k << endl;
    sc_time t2l( v6, SC_NS );
    cout << t2l << endl;
    sc_time t2m( v7, SC_NS );
    cout << t2m << endl;
    sc_time t2n( v8, SC_NS );
    cout << t2n << endl;
    sc_time t2o( v9, SC_NS );
    cout << t2o << endl;
    sc_time t2p( v10, SC_NS );
    cout << t2p << endl;
    sc_time t2q( v11, SC_NS );
    cout << t2q << endl;

    sc_time t3a( 0, SC_SEC );
    cout << t3a << endl;

    sc_time t3b( 1.2341, true );
    cout << t3b << endl;
    sc_time t3c( 1.2345, true );
    cout << t3c << endl;
    sc_time t3d( -1.2341, true );
    cout << t3d << endl;
    sc_time t3e( -1.2345, true );
    cout << t3e << endl;

    sc_time t3f( 1.2345, false );
    cout << t3f << endl;
    sc_time t3g( 1.5432, false );
    cout << t3g << endl;
    sc_time t3h( -1.2345, false );
    cout << t3h << endl;
    sc_time t3i( -1.5432, false );
    cout << t3i << endl;

#if !defined( _MSC_VER )
    sc_time t4a( 0ull, true );
    cout << t4a << endl;
    sc_time t4b( 25ull, true );
    cout << t4b << endl;
    sc_time t4c( 25ull, false );
    cout << t4c << endl;
#else
    sc_time t4a( 0ui64, true );
    cout << t4a << endl;
    sc_time t4b( 25ui64, true );
    cout << t4b << endl;
    sc_time t4c( 25ui64, false );
    cout << t4c << endl;
#endif

    sc_time t5( t4c );
    cout << t5 << endl;
}
示例#3
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;
}