本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例5:
~PtrGuard()
{
if( container != NULL)
for( SizeT s=container->size(); s > cSize; s--)
{
delete container->back();
container->pop_back();
}
}
示例6: main
int
main (void)
{
T x;
const T y;
x.display (10);
y.display (20);
return 0;
}
示例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;
}
示例8: init
void init() {
if(pointee != NULL) {
if(!pointee->isShareable()) {
pointee = new T(*pointee);
}
else {
pointee->addReference();
}
}
}
示例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);
}
示例10: run
virtual void run()
{
ops = 0;
while( LB_LIKELY( _running ))
{
lock->set();
#ifndef _MSC_VER
TEST( lock->isSet( ));
#endif
lock->unset();
++ops;
}
}
示例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);
}
示例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());
}
}
示例13: reset
void reset()
{
xp.reset();
yp.reset();
zp.reset();
pp.reset();
}
示例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();
}
示例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;
}