当前位置: 首页>>代码示例>>C++>>正文


C++ T类代码示例

本文整理汇总了C++中T的典型用法代码示例。如果您正苦于以下问题:C++ T类的具体用法?C++ T怎么用?C++ T使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了T类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_checked_multiply

constexpr bool test_checked_multiply(
    T v1,
    T v2,
    char expected_result
){
    using namespace boost::safe_numerics;
    const T result = v1 * v2;
    switch(expected_result){
    case '0':
    case '.':
        if(result.exception()){
            return false;
        }
        if(expected_result == '0'
        && result != T(0)
        ){
           return false;
        }
        return true;
    case '-':
        return safe_numerics_error::negative_overflow_error == result.m_e;
    case '+':
        return safe_numerics_error::positive_overflow_error == result.m_e;
    case '!':
        return safe_numerics_error::range_error == result.m_e;
    }
    return false;
}
开发者ID:robertramey,项目名称:safe_numerics,代码行数:28,代码来源:test_checked_multiply_constexpr.cpp

示例2: compute_boundary

  MatrixXi compute_boundary()
  {
    std::vector<std::pair<size_t, size_t> > bd;
    // for (T::All_edges_iterator it = _t.all_edges_begin();
    // 	 it != _t.all_edges_end(); ++it)
    for (T::Finite_edges_iterator it = _t.finite_edges_begin();
	 it != _t.finite_edges_end(); ++it)
      {
	T::Edge e = *it;
	// std::cerr << e.first->vertex(e.second)->info()
	// 	  << " -> ["
	// 	  << e.first->vertex((e.second+1)%3)->info() << ", "
	// 	  << e.first->vertex((e.second+2)%3)->info() << "]\n";
	if (_t.is_infinite(e.first->vertex(e.second)))
	  {
	    int i1= e.first->vertex((e.second+1)%3)->info();
	    int i2= e.first->vertex((e.second+2)%3)->info();
	    bd.push_back(std::make_pair(i1,i2));
	  }
      }
    size_t N = bd.size();
    MatrixXi X(N, 2);
    for (size_t i = 0; i < N; ++i)
      {
	X(i,0) = bd[i].first;
	X(i,1) = bd[i].second;
      }
    return X;
  }
开发者ID:mrgt,项目名称:PyMongeAmpere,代码行数:29,代码来源:MongeAmpere.cpp

示例3: ClientSession

	/// Ctor. Prepares session for connection as an initiator.
	ClientSession (const F8MetaCntx& ctx, const std::string& conf_file,
		const std::string& session_name, bool init_con_later=false) :
		ClientSessionBase(ctx, conf_file, session_name),
		_sci(get_sender_comp_id(_ses)), _tci(get_target_comp_id(_ses)),
		_id(_ctx._beginStr, _sci, _tci),
		_log(create_logger(_ses, session_log, &_id)),
		_plog(create_logger(_ses, protocol_log, &_id)),
		_persist(create_persister(_ses, nullptr, this->_loginParameters._reset_sequence_numbers)),
		_session(new T(_ctx, _id, _persist, _log, _plog)),
		_addr(get_address(_ses))
#ifdef FIX8_HAVE_OPENSSL
		,_ssl(get_ssl_context(_ses), true)
#endif
	{
		if (!init_con_later)
		{
#ifdef FIX8_HAVE_OPENSSL
			bool secured(_ssl.is_secure());
			_sock = secured
				? new Poco::Net::SecureStreamSocket(_ssl._context)
				: new Poco::Net::StreamSocket;
#else
			bool secured(false);
			_sock = new Poco::Net::StreamSocket;
#endif
			_cc = new ClientConnection(_sock, _addr, *_session, this->_loginParameters._hb_int, get_process_model(_ses), true, secured);
		}

		_session->set_login_parameters(this->_loginParameters);
		_session->set_session_config(this);
	}
开发者ID:19199883,项目名称:gangof4,代码行数:32,代码来源:sessionwrapper.hpp

示例4: GetNodes

	// return all nodes matching the volume-query
	// description, starting search at the subtree
	// with node-index <nodeNum>
	//
	// NOTE: do not call before balancing the tree
	void GetNodes(NodeVolumeQuery<T>* query, size_t nodeNum, unsigned int depth = 0) {
		if (nodeNum >= nodes.size()) {
			return;
		}

		const T nodeInst = nodes[nodeNum];
		float nodeDist = 0.0f;

		if ((nodeNum << 1) < nodes.size()) {
			// if in the left half of the array, we can examine child nodes
			nodeDist = query->GetPos()[nodeInst->GetAxis()] - nodeInst->GetPos()[nodeInst->GetAxis()];

			if (nodeDist > 0.0f) {
				// search right of the axis-plane first
				GetNodes(query, (nodeNum << 1) + 1, depth + 1);

				if ((nodeDist * nodeDist) < query->GetMaxNodeDist()) {
					GetNodes(query, (nodeNum << 1), depth + 1);
				}
			} else {
				// search left of the axis-plane first
				GetNodes(query, (nodeNum << 1), depth + 1);

				if ((nodeDist * nodeDist) < query->GetMaxNodeDist()) {
					GetNodes(query, (nodeNum << 1) + 1, depth + 1);
				}
			}
		}

		query->AddNode(nodeInst);
	}
开发者ID:rrti,项目名称:kiran,代码行数:36,代码来源:KDTree.hpp

示例5:

  ~PtrGuard()
  {
    if( container != NULL)
      for( SizeT s=container->size(); s > cSize; s--)
	{
	  delete container->back();
	  container->pop_back();
	}
  }
开发者ID:vedraiyani,项目名称:GDL,代码行数:9,代码来源:typedefs.hpp

示例6: main

int
main (void)
{
  T x;
  const T y;
  x.display (10);
  y.display (20);
  return 0;
}
开发者ID:rsadhu,项目名称:work,代码行数:9,代码来源:t.cpp

示例7: multipleEnd

void multipleEnd() {
  for (S::iterator i = s.begin(); i != s.end(); ++i)
    MutableVal k = *i;

  for (T::iterator i = t.begin(); i != t.end(); ++i)
    int k = *i;

  for (U::iterator i = u.begin(); i != u.end(); ++i)
    Val k = *i;
}
开发者ID:sam-panzer,项目名称:clang-loop-converter,代码行数:10,代码来源:negative-multi-end-call.cpp

示例8: init

 void init() {
     if(pointee != NULL) {
         if(!pointee->isShareable()) {
             pointee = new T(*pointee);
         }
         else {
             pointee->addReference();
         }
     }
 }
开发者ID:jsmarui,项目名称:five-minutes-algorithm,代码行数:10,代码来源:ReferenceCount.cpp

示例9: get_nan

T get_nan() {
    static T r;
    static bool init = false;

    if (!init) {
        init = true;
        r._data().make_nan();
    }

    return BOOST_XINT_MOVE(r);
}
开发者ID:vividos,项目名称:MultiplayerOnlineGame,代码行数:11,代码来源:internals.hpp

示例10: run

    virtual void run()
    {
        ops = 0;
        while( LB_LIKELY( _running ))
        {
            lock->set();
#ifndef _MSC_VER
            TEST( lock->isSet( ));
#endif
            lock->unset();
            ++ops;
        }
    }
开发者ID:VMML,项目名称:Lunchbox,代码行数:13,代码来源:lock.cpp

示例11:

void Hansen_example<T>::evaluate(const T v[]) const {

	const T& x = v[X];
	const T& y = v[Y];

	const T xy = x*y;

	xy.mark_as_common_subexpression();

	const T z = (5*x-4*sqr(y)+14*xy)/(sqr(x)+y+xy);

	z.equals(14.5);
}
开发者ID:baharev,项目名称:old_sandbox,代码行数:13,代码来源:Hansen.cpp

示例12: test

void test () {
#if _LIBCPP_STD_VER > 11
    {
        constexpr T sv1;
        static_assert ( sv1.size() == 0, "" );
        static_assert ( sv1.empty(), "");
    }
#endif

    {
        T sv1;
        assert ( sv1.size() == 0 );
        assert ( sv1.empty());
    }
}
开发者ID:0xDEC0DE8,项目名称:ndk,代码行数:15,代码来源:default.pass.cpp

示例13: reset

	void reset()
	{
		xp.reset();
		yp.reset();
		zp.reset();
		pp.reset();
	}
开发者ID:FionaCLin,项目名称:rUNSWift-2015-release,代码行数:7,代码来源:ExampleTAD3.cpp

示例14: Mutex

 Mutex(const std::string& s, bool exclusive=false)
     : m_lock(s.c_str())
 {
     if (exclusive)
         m_lock.lock();
     else
         m_lock.lock_sharable();
 }
开发者ID:troyh,项目名称:xmldb,代码行数:8,代码来源:Mutex.hpp

示例15: step

 void step() {
     while (stop == false ) {
         //cout << "Appending, i="<<i<<endl;
         while ( mlst->append( Dummy(i,i,i) ) ) { ++i; ++appends; }
         //cout << "Erasing, i="<<i<<endl;
         while ( mlst->erase( Dummy(i-1,i-1,i-1) ) ) { --i; ++erases; }
     }
     //cout << "Stopping, i="<<i<<endl;
 }
开发者ID:pelletierts,项目名称:orocos-rtt,代码行数:9,代码来源:buffers_test.cpp


注:本文中的T类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。