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

C++ pointer函数代码示例

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

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



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

示例1: TEST

TEST(TypeStructTest, map) 
{
    // packing
    auto p=refrange::msgpack::create_vector_packer();
    p << refrange::msgpack::map(1) << "key" << 1;

    // unpack
	auto u = refrange::msgpack::create_unpacker(p.pointer(), p.size());

    std::stringstream ss;
    refrange::msgpack::typestruct(u, ss);

    EXPECT_STREQ("{string:int}", ss.str().c_str());
}
开发者ID:ousttrue,项目名称:refrange,代码行数:14,代码来源:typestruct_test.cpp


示例2: pointer

   void Test::assignmentTest() {
      {
	 RefPtr pointer( new RefTest );
	 {
	    RefPtr pointer2;
	    pointer2 = pointer;
	 }
      }
      assert( 0 == s_construct );
   }
开发者ID:aehart,项目名称:cmssw,代码行数:10,代码来源:referencecounted_t.cpp


示例3: allocate

 pointer allocate(size_type obj_size)
 {
     if (is_memory_available()) {
         pointer ptr = m_chunk + (m_head * obj_size);
         m_head = ptr[0];
         m_available--;
         return ptr;
     }
     return pointer(nullptr);
 }
开发者ID:eucpp,项目名称:allocpp,代码行数:10,代码来源:memory_pool.hpp


示例4: displayMenu

void displayMenu(int y, int x, char title[],int numOfOpt, char *options[], void (*p[])(void)){
	int i,c;
	WINDOW *menuWindow;
	MENU *myMenu;
	ITEM **myOptions;
	ITEM *currentOption;
	initscr();
	noecho();
	cbreak();
	keypad(stdscr,TRUE);
	init_pair(1,COLOR_CYAN,COLOR_BLACK);
	myOptions=(ITEM **)calloc(numOfOpt+1,sizeof(ITEM *));
	for(i=0;i<numOfOpt;i++){
		myOptions[i]=new_item(options[i]," ");
		set_item_userptr(myOptions[i],p[i]);	
	}
	myOptions[numOfOpt]=(ITEM *)NULL;
	myMenu=new_menu(myOptions);
	menuWindow = newwin(8,20,(LINES-y)/2,(COLS-x)/2);
	keypad(menuWindow,TRUE);
	set_menu_win(myMenu,menuWindow);
	set_menu_sub(myMenu, derwin(menuWindow,y-4,x-2,3,1));
	set_menu_format(myMenu,numOfOpt,1);
	menu_opts_off(myMenu, O_SHOWDESC);
	set_menu_mark(myMenu," * ");
	post_menu(myMenu);
	wrefresh(menuWindow);
	while((c=wgetch(menuWindow))!=KEY_F(2)){
		switch(c){
			case KEY_UP:
				menu_driver(myMenu,REQ_UP_ITEM);
				break;
			case KEY_DOWN:
				menu_driver(myMenu,REQ_DOWN_ITEM);
				break;
			case 10:{
				ITEM *temp;
				temp=current_item(myMenu);
				void(*pointer)(void);
				pointer=item_userptr(temp);
				pointer();
				pos_menu_cursor(myMenu);
				menu_driver(myMenu,REQ_DOWN_ITEM);
				break;
				}
			wrefresh(menuWindow);
		}
	}
	/*unpost_menu(myMenu);*/
	/*for(i=0;i<numOfOpt;++i){*/
		/*free_item(myOptions[i]);*/
	/*}*/
	/*free_menu(myMenu);*/
	/*free(optionsNumbers);*/
}
开发者ID:nijen1312,项目名称:uczelnia,代码行数:55,代码来源:menufunctons.c


示例5: old

// if sizes==0, then keep current shape
int Data::realloc(Data::Type t, const int * sizes, int n){
	Data old(*this); // REV0

	if(sizes){		// new shape requested
		clear();
		shape(sizes, n);
	}
	else{			// just changing type, leave shape unchanged
//		Data old(*this); // REV0
		clear();
		shape(old.mSizes, old.maxDim());
	}	

	if(size()){
		mType  = t;
		mStride= 1;
		switch(type()){
		case Data::BOOL:	mData = pointer(new bool[size()]); break;
		case Data::INT:		mData = pointer(new int[size()]); break;
		case Data::FLOAT:	mData = pointer(new float[size()]); break;
		case Data::DOUBLE:	mData = pointer(new double[size()]); break;
		case Data::STRING:	mData = pointer(new std::string[size()]); break;
		default:			goto end;
		}
		acquire(mData);
		offset(0);
//		if(hasData() && isNumerical()) assignAll(0); // REV0

		if(hasData() && isNumerical()){
			if(old.hasData()){
				assign(old);	// copy over as many old elements as possible
				if(size() > old.size()) slice(old.size()).assignAll(0);
			}
			else{
				assignAll(0);
			}
		}
	}

	end:
	return sizeBytes() - old.sizeBytes();
}
开发者ID:eranws,项目名称:GLV,代码行数:43,代码来源:glv_model.cpp


示例6: size

//static const u32 mb_sz = 0x1000000;
bool CMemoryWriter::save_to(LPCSTR fn)
{
    IWriter* F = FS.w_open(fn);
    if (F)
    {
        F->w(pointer(), size());
        FS.w_close(F);
        return true;
    }
    return false;
}
开发者ID:BubbaXXX,项目名称:xray-16,代码行数:12,代码来源:FS.cpp


示例7: pointer

 bool NearSpansUnordered::isPayloadAvailable()
 {
     SpansCellPtr pointer(min());
     while (pointer)
     {
         if (pointer->isPayloadAvailable())
             return true;
         pointer = pointer->_next;
     }
     return false;
 }
开发者ID:alesha1488,项目名称:LucenePlusPlus,代码行数:11,代码来源:NearSpansUnordered.cpp


示例8: pointer

  IPC::MessagePointer IPC::IPCExceptionToMessage(const IPCException& exception)
  {
    IPC::Exception * const message = new IPC::Exception();
    IPC::MessagePointer pointer(message);

    message->set_context(exception.context());
    message->set_object(exception.object());
    message->set_reason(exception.reason());
    message->set_request_id(exception.messageID());

    return pointer;
  }
开发者ID:zaolin,项目名称:usbguard,代码行数:12,代码来源:IPCPrivate.cpp


示例9: Actor

Ghost::Ghost(Math::Point pos, Pointer<Entity> parent, QString name)
	:	Actor(parent, name),
		mKillCount(0)
{
	subclass();

	setPos(pos);
	setMaxSpeed(9.0);

	mPursue = new Pursue(pointer());
	mWander = new Wander(pointer());
	addSteeringBehavior(mPursue);
	addSteeringBehavior(mWander);

	PersonView* view = new PersonView(pointer(), Qt::green);
	//view->setColor(Qt::green); // HULK SMASH!  -- 20070108 iank
	setView(view);
	setVisible(true);

	newTarget();
}
开发者ID:tmandry,项目名称:adage,代码行数:21,代码来源:Ghost.cpp


示例10: find_chunk

//---------------------------------------------------
// base stream
IReader* IReader::open_chunk(u32 ID)
{
    BOOL bCompressed;

    u32 dwSize = find_chunk(ID, &bCompressed);
    if (dwSize != 0)
    {
        if (bCompressed)
        {
            BYTE* dest;
            unsigned dest_sz;
            _decompressLZ(&dest, &dest_sz, pointer(), dwSize);
            return xr_new<CTempReader>(dest, dest_sz, tell() + dwSize);
        }
        else
        {
            return xr_new<IReader>(pointer(), dwSize, tell() + dwSize);
        }
    }
    else return 0;
};
开发者ID:BubbaXXX,项目名称:xray-16,代码行数:23,代码来源:FS.cpp


示例11: proc_ffi_prep_cif

/*
 * (prepare-call-interface
 *   <foreign function ABI>
 *   <type of return value>
 *   (<type of input argument> ...))
 *
 *
 * TODO:
 * - Put ABI parameter last.
 * - If there is no input-value list, then ignore it.
 */
cons_t* proc_ffi_prep_cif(cons_t* p, environment_t*)
{
  assert_length(p, 2, 3);

  ffi_abi abi = FFI_DEFAULT_ABI;

  /*
   * ARGUMENT 1: ABI for foreign function
   */
  abi = parse_ffi_abi(car(p));

  /*
   * ARGUMENT 2:
   * Return type for foreign function
   */
  ffi_type* rtype = parse_ffi_type(cadr(p));

  /*
   * ARGUMENT 3:
   * Types for foreign function's input parameters.
   */
  ffi_type** argtypes = NULL;
  unsigned int nargs = 0;

  if ( length(p) >= 3 ) {
    cons_t *args = caddr(p);
    assert_type(PAIR, args);
    nargs = length(args);

    if ( nargs > 0 ) {
      argtypes = static_cast<ffi_type**>(malloc(nargs*sizeof(ffi_type*)));

      for ( unsigned int n=0; n<nargs; ++n ) {
        argtypes[n] = parse_ffi_type(car(args));
        args = cdr(args);
      }
    }
  }

  /*
   * Initialize returned struct
   */
  ffi_cif *cif = new ffi_cif();
  memset(cif, 0, sizeof(ffi_cif));

  check(ffi_prep_cif(cif, abi, nargs, rtype, argtypes));
  return pointer(tag_ffi_cif, cif);

  /*
   * In the future, the malloced argtypes should be added to the
   * pointer-return value here, so that it too can be freed.
   */
}
开发者ID:cslarsen,项目名称:mickey-scheme,代码行数:64,代码来源:ffi.cpp


示例12: main

int main(){
	double x=3.1, y=5.1;
	void (*pointer)(double, double);

	printf("add 함수의 주소 : %x\n",add);
	printf("함수 포인터의 주소 : %x\n",&pointer);

	pointer=add;
	pointer(x,y);

	return 0;
}
开发者ID:Phantomn,项目名称:C_language,代码行数:12,代码来源:funcpointer.c


示例13: retcode

void retcode(Tree p) {
	Type ty;

	if (p == NULL) {
		if (events.returns)
			apply(events.returns, cfunc, NULL);
		return;
	}
	p = pointer(p);
	ty = assign(freturn(cfunc->type), p);
	if (ty == NULL) {
		error("illegal return type; found `%t' expected `%t'\n",
			p->type, freturn(cfunc->type));
		return;
	}
	p = cast(p, ty);
	if (retv)
		{
			if (iscallb(p))
				p = tree(RIGHT, p->type,
					tree(CALL+B, p->type,
						p->kids[0]->kids[0], idtree(retv)),
					rvalue(idtree(retv)));
			else
				p = asgntree(ASGN, rvalue(idtree(retv)), p);
			walk(p, 0, 0);
			if (events.returns)
				apply(events.returns, cfunc, rvalue(idtree(retv)));
			return;
		}
	if (events.returns)
		{
			Symbol t1 = genident(AUTO, p->type, level);
			addlocal(t1);
			walk(asgn(t1, p), 0, 0);
			apply(events.returns, cfunc, idtree(t1));
			p = idtree(t1);
		}
	if (!isfloat(p->type))
		p = cast(p, promote(p->type));
	if (isptr(p->type))
		{
			Symbol q = localaddr(p);
			if (q && (q->computed || q->generated))
				warning("pointer to a %s is an illegal return value\n",
					q->scope == PARAM ? "parameter" : "local");
			else if (q)
				warning("pointer to %s `%s' is an illegal return value\n",
					q->scope == PARAM ? "parameter" : "local", q->name);
		}
	walk(tree(mkop(RET,p->type), p->type, p, NULL), 0, 0);
}
开发者ID:0culus,项目名称:ioq3,代码行数:52,代码来源:stmt.c


示例14: set_video_mode

/*
 * (set-video-mode <width> <height> <bits per pixel>?) or
 * (set-video-mode <width> <height> <bits per pixel> <mode flags>+)
 *
 * where <symbols> are:
 *  swsurface
 *  hwsurface
 *  asyncblit
 *  anyformat
 *  hwpalette
 *  doublebuf
 *  fullscreen
 *  opengl
 *  openglblit
 *  resizable
 *  noframe
 *
 */
cons_t* set_video_mode(cons_t* p, environment_t*)
{
  assert_length_min(p, 2);
  assert_type(INTEGER, car(p));
  assert_type(INTEGER, cadr(p));

  // dimension
  int x = intval(car(p));
  int y = intval(cadr(p));

  // default values
  int bits = 32;
  uint32_t mode = 0;

  // bits per pixel
  if ( length(p) > 2 && integerp(caddr(p)) )
    bits = intval(caddr(p));

  // mode options
  if ( length(p) > 3 ) {
    cons_t *opts = symbolp(caddr(p))? cddr(p) :
                   symbolp(cadddr(p))? cdddr(p) : nil();;

    DPRINT(opts);

    for ( cons_t *s = opts; !nullp(s); s = cdr(s) ) {
      assert_type(SYMBOL, car(s));

      std::string sym = symbol_name(car(s));

      for ( size_t n=0; n < num_sdl_flags; ++n )
        if ( sym == sdl_flags[n].key ) {
          mode |= sdl_flags[n].value;
          goto NEXT_FLAG;
        }

      raise(runtime_exception("Unknown SDL video mode flag: " + sym));

  NEXT_FLAG:
      continue;
    }
  }

  SDL_Surface *screen = SDL_SetVideoMode(x, y, bits, mode);

  if ( screen == NULL )
    raise(runtime_exception(SDL_GetError()));

  return pointer(
    new pointer_t("sdl-surface",
                  reinterpret_cast<void*>(screen)));
}
开发者ID:Fangang,项目名称:mickey-scheme,代码行数:70,代码来源:cross-platform-sdl.cpp


示例15: pointer

uint32 SymbianStdioStream::write(const void *ptr, uint32 len) {
	TPtrC8 pointer( (unsigned char*) ptr, len);

	((TSymbianFileEntry *)(_handle))->_inputPos = KErrNotFound;
	((TSymbianFileEntry *)(_handle))->_lastError = ((TSymbianFileEntry *)(_handle))->_fileHandle.Write(pointer);
	((TSymbianFileEntry *)(_handle))->_eofReached = EFalse;

	if (((TSymbianFileEntry *)(_handle))->_lastError == KErrNone) {
		return len;
	}

	return 0;
}
开发者ID:Bundesdrucker,项目名称:scummvm,代码行数:13,代码来源:symbianstream.cpp


示例16: expr3

static Tree expr3(int k) {
	int k1;
	Tree p = unary();

	for (k1 = prec[t]; k1 >= k; k1--)
		while (prec[t] == k1 && *cp != '=') {
			Tree r;
			Coordinate pt;
			int op = t;
			t = gettok();
			pt = src;
			p = pointer(p);
			if (op == ANDAND || op == OROR) {
				r = pointer(expr3(k1));
				if (events.points)
					apply(events.points, &pt, &r);
			} else
				r = pointer(expr3(k1 + 1));
			p = (*optree[op])(oper[op], p, r); 
		}
	return p;
}
开发者ID:DCPUTools,项目名称:dcpu16-lcc,代码行数:22,代码来源:expr.c


示例17: Trials

int CMSimulationArray::MakeKey(const CMTime& t,int var)
{
	if (var<0 || var>=nvars || t<beg || t>end || !array || Fail())
		return 0;

	if (key) delete key;
	long ntrials = Trials();
	key = new CMVSBigArray<pointer>(ntrials,1);
	for (long i=0;key && i<ntrials;i++)
		key->Add(pointer(At(t,var,i),i));
	key->Sort();
	return (key != 0);
}
开发者ID:caseymcspadden,项目名称:IRPSIM,代码行数:13,代码来源:simarray.cpp


示例18: do_release

  void do_release() {
    size_t total_bytes = *count_ * sizeof(T);
    
    RequestArgs args;
    args.request_address = *request_address_;
    DVLOG(5) << "Computing request_bytes from block_max " << request_address_->first_byte().block_max() << " and " << *request_address_;
    args.reply_address = make_global( this );
    size_t offset = 0;
    size_t request_bytes = 0;

    for( size_t i = 0;
         offset < total_bytes; 
         offset += request_bytes, i++) {

      request_bytes = args.request_address.first_byte().block_max() - args.request_address.first_byte();

      if( request_bytes > total_bytes - offset ) {
        request_bytes = total_bytes - offset;
      }

      DVLOG(5) << "sending release request with " << request_bytes
               << " of total bytes = " << *count_ * sizeof(T)
               << " to " << args.request_address;

      Grappa::send_heap_message(args.request_address.core(),
        [args](void * payload, size_t payload_size) {
          IRMetrics::count_release_ams( payload_size );
          DVLOG(5) << "Worker " << Grappa::current_worker()
          << " received release request to " << args.request_address
          << " reply to " << args.reply_address;
          memcpy( args.request_address.pointer(), payload, payload_size );
    
          auto reply_address = args.reply_address;
          Grappa::send_heap_message(args.reply_address.core(), [reply_address]{
            DVLOG(5) << "Worker " << Grappa::current_worker() << " received release reply to " << reply_address;
            reply_address.pointer()->release_reply();
          });
    
          DVLOG(5) << "Worker " << Grappa::current_worker()
          << " sent release reply to " << reply_address;
        },
        (char*)(*pointer_) + offset, request_bytes
      );

      // TODO: change type so we don't screw with pointer like this
      args.request_address = GlobalAddress<T>::Raw( args.request_address.raw_bits() + request_bytes );
    }
    DVLOG(5) << "release started for " << args.request_address;
    
    // blocks here waiting for messages to be sent
  }
开发者ID:HTOKORG,项目名称:grappa,代码行数:51,代码来源:IncoherentReleaser.hpp


示例19: expr2

static Tree expr2(void) {
	Tree p = expr3(4);

	if (t == '?') {
		Tree l, r;
		Coordinate pts[2];
		if (Aflag > 1 && isfunc(p->type))
			warning("%s used in a conditional expression\n",
				funcname(p));
		p = pointer(p);
		t = gettok();
		pts[0] = src;
		l = pointer(expr(':'));
		pts[1] = src;
		r = pointer(expr2());
		if (events.points) {
			apply(events.points, &pts[0], &l);
			apply(events.points, &pts[1], &r);
		}
		p = condtree(p, l, r);
	}
	return p;
}
开发者ID:OpenArena,项目名称:gamecode,代码行数:23,代码来源:expr.c


示例20:

void	IReader::r	(void *p,int cnt)
{
	VERIFY			(Pos+cnt<=Size);
	CopyMemory		(p,pointer(),cnt);
	advance			(cnt);
#ifdef DEBUG
	BOOL	bShow		= FALSE		;
	if (dynamic_cast<CFileReader*>(this))			bShow = TRUE;
	if (dynamic_cast<CVirtualFileReader*>(this))	bShow = TRUE;
	if (bShow)			{
  		FS.dwOpenCounter	++		;
	}
#endif
};
开发者ID:2asoft,项目名称:xray,代码行数:14,代码来源:FS.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pointer_delta函数代码示例发布时间:2022-05-30
下一篇:
C++ point_sub函数代码示例发布时间: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