• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ precondition函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: dpCheckAppVersion

/*----------------------------------------------------------------------
 Determine whether application *app needs to be updated.
 Returns latest app version from game server in *app.
 Not needed by most user programs.

 Returns dp_RES_OK if update needed,
 dp_RES_EMPTY if no update needed.
----------------------------------------------------------------------*/
DP_API dp_result_t DP_APIX dpCheckAppVersion(
	dp_t* dp,
	dp_appParam_t *app)
{
    precondition(dp);
    precondition(app);

	getLatest(dp, app);   /* Ignore errors */

	if ((app->latest.major == dp_VERS_UNKNOWN)
	||  (app->latest.minor == dp_VERS_UNKNOWN)) {
		DPRINT(("dpCheckAppVersion: no version info available for this app?\n"));
		return dp_RES_EMPTY;
	}
	if ((app->current.major > app->latest.major)
	||  ((app->current.major == app->latest.major)
	   && (app->current.minor >= app->latest.minor))) {
		DPRINT(("dpCheckAppVersion: this app is up to date.\n"));
		return dp_RES_EMPTY;
	}

	DPRINT(("dpCheckAppVersion: app needs updating: version cur %d/%d < latest %d/%d\n", 
			app->current.major, app->current.minor,
			app->latest.major, app->latest.minor));
	return dp_RES_OK;
}
开发者ID:talentlesshack,项目名称:C2P2,代码行数:34,代码来源:enumapp.c


示例2: precondition

BOOL Bsc1::getOverloadArray(SZ sz, MBF mbf, OUT IINST **ppiinst, OUT ULONG *pciinst)
{
    precondition(ppiinst);
    precondition(pciinst);
    IINST *rgiinst;
    ULONG cIinst;

    if (sz && sz[0] && sz[0] != '*') {
		Array<IINST> arIinst;
		parIinst = &arIinst;
		pbscCur  = this;
		GenerateOverloads(sz, mbf, GatherOverloads,this);
		cIinst = arIinst.size();
        rgiinst = (IINST*)malloc(cIinst*sizeof(IINST));
        if (!rgiinst) return FALSE;
	
		for (UINT i=0; i < cIinst; i++)
		    rgiinst[i] = arIinst[i];
    }
    else {
        rgiinst = (IINST*)malloc(cEntities*sizeof(IINST));
        if (!rgiinst) return FALSE;

        cIinst = 0;

        for (UINT i = 0; i < cEntities; i++) {
    	    if (fInstFilter(i, mbf) && fHasDefsOrRefs(i))
	    		rgiinst[cIinst++] = i;
        }
    }

    *ppiinst = rgiinst;
    *pciinst = cIinst;
    return TRUE;
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:35,代码来源:bsc1.cpp


示例3: amg

        amg(const Matrix &M, const params &p = params()) : prm(p)
        {
            precondition(
                    backend::rows(M) == backend::cols(M),
                    "Matrix should be square!"
                    );

            boost::shared_ptr<build_matrix> P, R;
            boost::shared_ptr<build_matrix> A = boost::make_shared<build_matrix>( M );
            sort_rows(*A);

            while( backend::rows(*A) > prm.coarse_enough) {
                TIC("transfer operators");
                boost::tie(P, R) = Coarsening::transfer_operators(
                        *A, prm.coarsening);
                precondition(
                        backend::cols(*P) > 0,
                        "Zero-sized coarse level in amgcl (diagonal matrix?)"
                        );
                TOC("transfer operators");

                TIC("move to backend")
                levels.push_back( level(A, P, R, prm) );
                TOC("move to backend")

                TIC("coarse operator");
                A = Coarsening::coarse_operator(*A, *P, *R, prm.coarsening);
                sort_rows(*A);
                TOC("coarse operator");
            }

            TIC("coarsest level");
            levels.push_back( level(A, prm, levels.empty()) );
            TOC("coarsest level");
        }
开发者ID:intbots,项目名称:amgcl,代码行数:35,代码来源:amgcl.hpp


示例4: precondition

int64_t
sample_rate::resample( int64_t i, const sample_rate &rate ) const
{
	precondition( _ratio.valid(), "invalid destination sample rate" );
	precondition( rate._ratio.valid(), "invalid source sample rate" );
	base::ratio tmp = i * ( _ratio / rate._ratio );
	return tmp.round();
}
开发者ID:kdt3rd,项目名称:gecko,代码行数:8,代码来源:sample_rate.cpp


示例5: precondition

void Loader::compositionExit()
{
  precondition(component != nullptr);
  precondition(composition != nullptr);

  component->setImplementation(composition);
  composition = nullptr;
}
开发者ID:ursfassler,项目名称:evdraw,代码行数:8,代码来源:XmlReader.cpp


示例6: precondition

void DrawPort::removeConnectionPoint(RelativePosition *point)
{
  precondition(point->hasAnchor());
  precondition(point->getAnchor() == &this->getPosition());

  point->removeAnchor();

  postcondition(!point->hasAnchor());
}
开发者ID:ursfassler,项目名称:evdraw,代码行数:9,代码来源:DrawPort.cpp


示例7: PDBAPI

// create a BSC object using an existing PDB
PDBAPI(BOOL) Bsc::open(PDB* ppdb, OUT Bsc** ppbsc)
{
    precondition(ppbsc);
    precondition(ppdb);

    Bsc1* pbsc1 = new Bsc1;

    *ppbsc = pbsc1;
    if (!pbsc1) return FALSE;

    return pbsc1->init(ppdb);
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:13,代码来源:bsc1.cpp


示例8: read_dense

void read_dense(const std::string &fname, SizeT &n, SizeT &m, std::vector<Val> &v)
{
    std::ifstream f(fname.c_str(), std::ios::binary);
    precondition(f, "Failed to open matrix file");

    precondition(read(f, n), "File I/O error");
    precondition(read(f, m), "File I/O error");

    v.resize(n * m);

    precondition(read(f, v), "File I/O error");
}
开发者ID:HongLi15,项目名称:amgcl,代码行数:12,代码来源:binary.hpp


示例9: precondition

BOOL
MRE::FDelete() {
	precondition ( m_pstreamFileInfo );
	precondition ( m_pstreamClassMods );
	precondition ( m_pstreamFileMods );
	precondition ( m_pstreamRudeFiles );

	_TCHAR		szStreamName[ ctchMrePathMax ];
	Stream *	pstream;
	EnumMapNiFi	e(m_mpnifi);

	m_mrelog.LogNote ( "Note: deleting all streams.\n" );

	// enumerate all the src file streams
	while ( e.next() ) {
		PFI	pfi;
		NI	ni;
		e.get ( &ni, &pfi );
		assert ( ni == pfi->niFile );
		if ( pfi->FHasTarget() ) {
			pfi->SetFstatus ( fsmOutOfDate );
			_sntprintf ( szStreamName, countof(szStreamName), c_szMreFileFmt, ni );
			if ( m_ppdb->OpenStream ( szStreamName, &pstream ) ) {
				pstream->Truncate ( 0 );
				pstream->Release();
				}
			}
		}

	// invalidate the current buffer, if any
	m_mrfibufRoot.FInitEmpty();
	
	// get rid of the various streams
	m_pstreamClassInfo->Truncate ( 0 );
	m_pstreamClassMods->Truncate ( 0 );
	m_pstreamFileMods->Truncate ( 0 );
	m_pstreamRudeFiles->Truncate ( 0 );
	
	// get rid of the line change record data
	m_lcrechandler.Delete();
	
	// reset all the in memory copies of the streams
	m_mpnici.reset();
	m_rgtagniPending.reset();
	m_rgtagclsdep.reset();
	m_rgtagniRude.reset();
	m_itagclsdepSav = m_rgtagclsdep.size();
	m_ftagniPendingDirty = fFalse;
	m_itagniRudeSav = m_rgtagniRude.size();

	return fTrue;
	}
开发者ID:mingpen,项目名称:OpenNT,代码行数:52,代码来源:mre.cpp


示例10: ilu0

    ilu0( const Matrix &A, const params &, const typename Backend::params&)
        : luval( A.val ),
          dia  ( backend::rows(A) )
    {
        const size_t n = backend::rows(A);
        const value_type eps = amgcl::detail::eps<value_type>(1);

        std::vector<ptrdiff_t> work(n, -1);

        for(size_t i = 0; i < n; ++i) {
            ptrdiff_t row_beg = A.ptr[i];
            ptrdiff_t row_end = A.ptr[i + 1];

            for(ptrdiff_t j = row_beg; j < row_end; ++j)
                work[ A.col[j] ] = j;

            for(ptrdiff_t j = row_beg; j < row_end; ++j) {
                ptrdiff_t c = A.col[j];

                // Exit if diagonal is reached
                if (static_cast<size_t>(c) >= i) {
                    precondition(
                            static_cast<size_t>(c) == i,
                            "No diagonal value in system matrix"
                            );
                    precondition(
                            fabs(luval[j]) > eps,
                            "Zero pivot in ILU"
                            );

                    dia[i]   = j;
                    luval[j] = 1 / luval[j];
                    break;
                }

                // Compute the multiplier for jrow
                value_type tl = luval[j] * luval[dia[c]];
                luval[j] = tl;

                // Perform linear combination
                for(ptrdiff_t k = dia[c] + 1; k < A.ptr[c + 1]; ++k) {
                    ptrdiff_t w = work[A.col[k]];
                    if (w >= 0) luval[w] -= tl * luval[k];
                }
            }

            // Refresh work
            for(ptrdiff_t j = row_beg; j < row_end; ++j)
                work[A.col[j]] = -1;
        }
    }
开发者ID:intbots,项目名称:amgcl,代码行数:51,代码来源:ilu0.hpp


示例11: reduce_by_key_sink

int reduce_by_key_sink(
        IKTuple &&ikeys, vector<V> const &ivals,
        OKTuple &&okeys, vector<V>       &ovals,
        Comp, Oper
        )
{
    namespace fusion = boost::fusion;
    typedef typename extract_value_types<IKTuple>::type K;

    static_assert(
            std::is_same<K, typename extract_value_types<OKTuple>::type>::value,
            "Incompatible input and output key types");

    precondition(
            fusion::at_c<0>(ikeys).nparts() == 1 && ivals.nparts() == 1,
            "reduce_by_key is only supported for single device contexts"
            );

    precondition(fusion::at_c<0>(ikeys).size() == ivals.size(),
            "keys and values should have same size"
            );

    const auto &queue = fusion::at_c<0>(ikeys).queue_list();
    backend::select_context(queue[0]);

    const int NT_cpu = 1;
    const int NT_gpu = 256;
    const int NT = is_cpu(queue[0]) ? NT_cpu : NT_gpu;

    size_t count         = fusion::at_c<0>(ikeys).size();
    size_t num_blocks    = (count + NT - 1) / NT;
    size_t scan_buf_size = alignup(num_blocks, NT);

    backend::device_vector<int> key_sum   (queue[0], scan_buf_size);
    backend::device_vector<V>   pre_sum   (queue[0], scan_buf_size);
    backend::device_vector<V>   post_sum  (queue[0], scan_buf_size);
    backend::device_vector<V>   offset_val(queue[0], count);
    backend::device_vector<int> offset    (queue[0], count);

    /***** Kernel 0 *****/
    auto krn0 = offset_calculation<K, Comp>(queue[0]);

    krn0.push_arg(count);
    boost::fusion::for_each(ikeys, do_push_arg(krn0));
    krn0.push_arg(offset);

    krn0(queue[0]);

    VEX_FUNCTION(int, plus, (int, x)(int, y), return x + y;);
开发者ID:DingKe,项目名称:vexcl,代码行数:49,代码来源:reduce_by_key.hpp


示例12: dp_freezeAppsList

/*--------------------------------------------------------------------------
Save the apps list to disk.
(Called at quit time to provide quick info on next startup).
--------------------------------------------------------------------------*/
dp_result_t			/* status */
dp_freezeAppsList(
	dp_t *dp)		/* Owner of apps table */
{
	FILE* fp;
	dp_result_t err = dp_RES_OK;

	precondition(dp != NULL);
	precondition(dp->dpio != NULL);

	DPRINT(("dp_freezeAppsList:\n"));

	if (!dp->apps || (dptab_tableSize(dp->apps) == 0)) {
		DPRINT(("dptab_table_freeze: table has no entry\n"));
		return dp_RES_OK;
	}

	/* Get the file */
	fp = fopen(APPS_CACHE_FILE, "wb");
	if (fp == NULL) {
		DPRINT(("dp_freezeAppsList: can't open %s, errno %d\n", APPS_CACHE_FILE, errno));
		return dp_RES_FULL;
	}

	/* Write the info (either NULL or a table) */
	if(dp->apps != NULL) {
		char c = 1;
		if(fwrite(&c, sizeof(char), 1, fp) != 1) {
			fclose(fp);
			DPRINT(("dp_freezeAppsList: can't write %s, errno %d\n", APPS_CACHE_FILE, errno));
			return dp_RES_FULL;
		}
		err = dptab_table_freeze(dp->apps, dp->dpio, fp);
		DPRINT(("dp_freezeAppsList: fp now at %ld\n", ftell(fp)));
	} else {
		char c = 0;
		if(fwrite(&c, sizeof(char), 1, fp) != 1) {
			fclose(fp);
			DPRINT(("dp_freezeAppsList: can't write %s, errno %d\n", APPS_CACHE_FILE, errno));
			return dp_RES_FULL;
		}
	}

	/* Finish the file */
	fclose(fp);
	DPRINT(("dp_freezeAppsList: returning err:%d\n", err));
	return err;
}
开发者ID:talentlesshack,项目名称:C2P2,代码行数:52,代码来源:enumapp.c


示例13: precondition

void ComponentFactory::dispose(IComponent *component)
{
  precondition(component != nullptr);

  cleanup(*component);
  delete component;
}
开发者ID:ursfassler,项目名称:evdraw,代码行数:7,代码来源:ComponentFactory.cpp


示例14: block_matrix_adapter

 block_matrix_adapter(const Matrix &A) : A(A) {
     precondition(
             backend::rows(A) % BlockSize == 0 &&
             backend::cols(A) % BlockSize == 0,
             "Matrix size is not divisible by block size!"
             );
 }
开发者ID:ddemidov,项目名称:amgcl,代码行数:7,代码来源:block_matrix.hpp


示例15: copy_vector

    // Copy vector from builtin backend.
    static boost::shared_ptr<vector>
    copy_vector(typename builtin<real>::vector const &x, const params &prm)
    {
        precondition(!prm.context().empty(), "Empty VexCL context!");

        return boost::make_shared<vector>(prm.context(), x);
    }
开发者ID:ttnghia,项目名称:amgcl,代码行数:8,代码来源:vexcl.hpp


示例16: create_vector

    // Create vector of the specified size.
    static boost::shared_ptr<vector>
    create_vector(size_t size, const params &prm)
    {
        precondition(!prm.context().empty(), "Empty VexCL context!");

        return boost::make_shared<vector>(prm.context(), size);
    }
开发者ID:ttnghia,项目名称:amgcl,代码行数:8,代码来源:vexcl.hpp


示例17: in_numeric_range

std::string in_numeric_range(cmdline_param const & param, char const * value,
    void const * range_info) {

    const char * const MSG = "Error with {1}=\"{2}\": expected a value between "
        "{3=min} and {4=max} (inclusive), formatted as {5}.";
    precondition(range_info != nullptr);

    numeric_range_info const & nri =
        *reinterpret_cast<numeric_range_info const *>(range_info);
    number_info info;
    auto ptr_to_null_char = strchr(value, 0);
    auto end = scan_number(value, ptr_to_null_char, nri.allowed_formats, info);
    auto valid = (end == ptr_to_null_char);
    if (valid) {
        if (info.format == numeric_formats::floating_point_only) {
            if (!std::isnan(nri.min) && info.floating_point < nri.min) {
                valid = false;
            } else if (!std::isnan(nri.max) && info.floating_point > nri.max) {
                valid = false;
            }
        } else {
            int64_t n = static_cast<int64_t>(info.whole_number);
            if (info.negative) {
                n *= -1;
            }
            valid = n >= nri.min && n <= nri.max;
        }
    }
    return valid ? "" :
        interp(MSG, {param.get_preferred_name(), value, nri.min, nri.max,
            get_names_for_numeric_formats(nri.allowed_formats)});
}
开发者ID:dhh1128,项目名称:intent,代码行数:32,代码来源:cmdline_validators.cpp


示例18: dpAccountLogin

/*------------------------------------------------------------------------
 Call this function after receiving a packet telling you to activate
 your account in response to dpAccountLogin() or dpAccountCreate()
 to activate your account.

 'secretcode' is the secret code emailed to you by the server when the
              account was created.
------------------------------------------------------------------------*/
DP_API dp_result_t DP_APIX dpAccountActivateW(
	dp_t *dp,
	const wchar_t *secretcode)
{
	precondition(dp);
	return tserv_account_activateW(dp->tserv, secretcode);
}
开发者ID:jleclanche,项目名称:darkdust-ctp2,代码行数:15,代码来源:dpuser.c


示例19: precondition

void parser::parse_comment( std::istream &in )
{
	precondition( in.get() == '/', "missing '/' to start comment" );
	while ( in.peek() == '/' )
		in.get();

	_func.add( '/' );
	_func.add( '/' );
	_func.add( ' ' );

	while ( !in.eof() && in )
	{
		int c = in.get();
		if ( std::char_traits<char>::not_eof( c ) )
		{
			if ( c == ']' )
				break;
			else
				_func.add( static_cast<char>( c ) );
		}
	}
	_func.push_code();
	if ( in.peek() == '\n' )
		in.get();
}
开发者ID:kdt3rd,项目名称:gecko,代码行数:25,代码来源:parser.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pred函数代码示例发布时间:2022-05-30
下一篇:
C++ precision函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap