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


C++ do_something函数代码示例

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


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

示例1: test

void test() {
  if (cond("if1") /*comment*/) do_something("same-line");

  if (cond("if2"))
    do_something("single-line");
  // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: statement should be inside braces
  // CHECK-FIXES: if (cond("if2")) {
  // CHECK-FIXES: }

  if (cond("if3") /*comment*/)
    // some comment
    do_something("three"
                 "lines");
  // CHECK-MESSAGES: :[[@LINE-4]]:31: warning: statement should be inside braces
  // CHECK-FIXES: if (cond("if3") /*comment*/) {
  // CHECK-FIXES: }

  if (cond("if4") /*comment*/)
    // some comment
    do_something("many"
                 "many"
                 "many"
                 "many"
                 "lines");
  // CHECK-MESSAGES: :[[@LINE-7]]:31: warning: statement should be inside braces
  // CHECK-FIXES: if (cond("if4") /*comment*/) {
  // CHECK-FIXES: }
}
开发者ID:GameFusion,项目名称:clang-tools-extra,代码行数:28,代码来源:readability-braces-around-statements-same-line.cpp

示例2: main

int main(int argc,char *argv[])
{
    int rank, num_of_processes;
    int i;

    MPI_Comm comm = MPI_COMM_WORLD;

    MPI_Init(&argc,&argv);
    MPI_Comm_size( comm, &num_of_processes);
    MPI_Comm_rank( comm, &rank);

    int localsum = 0;
    int globalsum = 0;
    int expectedsum = 0;
    
    if(rank == 0) {
        printf("Checking mpi_scan(sum)... (if you see no output then you are good)\n");
    }

    localsum = do_something(rank, 2);
    globalsum = 0;
    MPI_Scan(&localsum,&globalsum,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);

    expectedsum = 0;
    // count upto my rank and verify that that was the return from scan
    for(i=0; i<rank+1; i++) {
        expectedsum = expectedsum + do_something(i, 2);
    }
        
    if (globalsum != expectedsum) {
        printf("ERROR: Expected %d got %d [rank:%d]\n", expectedsum, globalsum, rank);
    }
        
    MPI_Finalize();
}
开发者ID:bryanmills,项目名称:srmpi,代码行数:35,代码来源:scan_test.c

示例3: test_switch

int
test_switch (int i, int j)
{
  int result = 0;			/* count(5) */

  switch (i)				/* count(5) */
    {
      case 1:
        result = do_something (2);	/* count(1) */
        break;
      case 2:
        result = do_something (1024);
        break;
      case 3:
      case 4:
        if (j == 2)			/* count(3) */
          return do_something (4);	/* count(1) */
        result = do_something (8);	/* count(2) */
        break;
      default:
	result = do_something (32);	/* count(1) */
	switch_m++;			/* count(1) */
        break;
    }
  return result;			/* count(4) */
}
开发者ID:VargMon,项目名称:dd-wrt,代码行数:26,代码来源:gcov-4.c

示例4: main

int
main(int argc, const char* argv[])
{
    printf("--> main()\n");
    do_something();

    hrt_tstamp t0, t1;
    hrt_tnull(&t0);
    hrt_tnull(&t1);

    printf("\nmarking time...\n");
    int r;
    if ((r = hrt_tnow(&t0)) != 0) {
        fprintf(stderr, "error: hrt_now(&t0) returned %d\n", r);
    }
    hrt_tprint(&t0);

    do_something();

    printf("\nmarking time...\n");
    if ((r = hrt_tnow(&t1)) != 0) {
        fprintf(stderr, "error: hrt_now(&t1) returned %d\n", r);
    }
    hrt_tprint(&t1);

    printf("\namount of times:\n");
    double rtmicros = hrt_rtmicros(&t1.rtstamp, &t0.rtstamp);
    double ctmicros = hrt_ctmicros(&t1.ctstamp, &t0.ctstamp);
    printf("real   = %.3f us\n", rtmicros);
    printf("cpu    = %.3f us\n", ctmicros);
    
    printf("\n<-- main()\n");
    return 0;
}
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:34,代码来源:hrt_utils_test.c

示例5: pack_unpack

int
pack_unpack (char *s, char *p)
{
  char *send, *pend;
  char type;
  int integer_size;

  send = s + strlen (s);
  pend = p + strlen (p);

  while (p < pend)
    {
      type = *p++;

      switch (type)
 {
 case 's':
   integer_size = 2;
   goto unpack_integer;

 case 'l':
   integer_size = 4;
   goto unpack_integer;

 unpack_integer:
   switch (integer_size)
     {
     case 2:
       {
  union
  {
    int16_t i;
    char a[sizeof (int16_t)];
  }
  v;
  memcpy (v.a, s, sizeof (int16_t));
  s += sizeof (int16_t);
  do_something (v.i);
       }
       break;

     case 4:
       {
  union
  {
    int32_t i;
    char a[sizeof (int32_t)];
  }
  v;
  memcpy (v.a, s, sizeof (int32_t));
  s += sizeof (int32_t);
  do_something (v.i);
       }
       break;
     }
   break;
 }
    }
  return (int) *s;
}
开发者ID:Derpybunneh,项目名称:cpctelera,代码行数:60,代码来源:gcc-torture-execute-20111208-1.c

示例6: main

int
main()
{
  do_something (2);
  do_something (3);
  do_something (5);
  do_something (70);
}
开发者ID:AlexMioMio,项目名称:gcc,代码行数:8,代码来源:inline-10.c

示例7: main

int main () {
    std::function<void(int, int)> lamarck = [&](int a, int b){ std::cout << a << b; };

    auto func = make_function([](){}); // lambda
    auto func2 = make_function(abc); // free function
    auto func3 = make_function(fo_abc()); // function object
    do_something(func);
    do_something(func2);
    do_something(func3);
}
开发者ID:CCJY,项目名称:coliru,代码行数:10,代码来源:main.cpp

示例8: test_ifelse3

int
test_ifelse3 (int i, int j)
{
  int result = 1;
  if (i > 10 && j > i && j < 20)	/* count(11) */
    result = do_something (16);		/* count(1) */
  if (i > 20)				/* count(11) */
    if (j > i)				/* count(5) */
      if (j < 30)			/* count(2) */
	result = do_something (32);	/* count(1) */
  if (i == 3 || j == 47 || i == j)	/* count(11) */
    result = do_something (64);		/* count(3) */
  return result;			/* count(11) */
}
开发者ID:VargMon,项目名称:dd-wrt,代码行数:14,代码来源:gcov-4.c

示例9: main

int main()
{
    do_something(A());
    do_something(A(10));
    
    // this will cause error
//    do_something(20);

    // call explicit conversion
    do_something(static_cast<A>(20));

    // not recommanded
    do_something((A)30);
    return 0;
}
开发者ID:Furzoom,项目名称:demo-C,代码行数:15,代码来源:explicit_constructor.cpp

示例10: foo

void foo(struct obj1 *op) {
	TESLA_WITHIN(context,
/*
 * TODO: use CHECK-DAG once we switch to LLVM 3.4:
 *
 * First, we need to look up op->child_of_1->child_of_2:
 * CHECK: [[PTR:%[_a-zA-Z0-9\.]+]] = getelementptr inbounds %struct.obj1* %op
 * CHECK: [[C:%[_a-zA-Z0-9\.]+]] = load %struct.obj2** [[PTR]]
 *
 * CHECK: [[PTR:%[_a-zA-Z0-9\.]+]] = getelementptr inbounds %struct.obj2* [[C]]
 * CHECK: [[CHILD:%[_a-zA-Z0-9\.]+]] = load %struct.obj1** [[PTR]]
 *
 * Next, we look up op->child_of_1->value:
 * CHECK: [[PTR:%[_a-zA-Z0-9\.]+]] = getelementptr inbounds %struct.obj1* %op
 * CHECK: [[C:%[_a-zA-Z0-9\.]+]] = load %struct.obj2** [[PTR]]
 *
 * CHECK: [[PTR:%[_a-zA-Z0-9\.]+]] = getelementptr inbounds %struct.obj2* [[C]]
 * CHECK: [[VALUE:%[_a-zA-Z0-9\.]+]] = load i32* [[PTR]]
 *
 * CHECK: call void [[INSTR:@.*_tesla_instr.*assert.*]](%struct.obj1* [[CHILD]], [[INT:i[3264]+]] [[VALUE]])
 */
		eventually(
			do_something(
				op->child_of_1->child_of_2,
				op->child_of_1->value) == 0
		)
	);
}
开发者ID:CTSRD-TESLA,项目名称:TESLA,代码行数:28,代码来源:field-lookup.c

示例11: process_data

	void process_data()
	{
		std::unique_lock<std::mutex> lk( get_lock() ); /* (1) */
		do_something();

		std::cout << "owns_lock : " << lk.owns_lock() << std::endl;
	} 
开发者ID:Ssangwoo,项目名称:CppConcurrencyInAction,代码行数:7,代码来源:lockmove.cpp

示例12: test_ifelse2

int
test_ifelse2 (int i)
{
  int result = 0;
  if (!i)				/* count(6) */
    result = do_something (1);		/* count(1) */
  if (i == 1)				/* count(6) */
    result = do_something (1024);
  if (i == 2)				/* count(6) */
    result = do_something (2);		/* count(3) */
  if (i == 3)				/* count(6) */
    return do_something (8);		/* count(2) */
  if (i == 4)				/* count(4) */
    return do_something (2048);
  return result;			/* count(4) */
}
开发者ID:VargMon,项目名称:dd-wrt,代码行数:16,代码来源:gcov-4.c

示例13: mainPlustHeaderCallAndReturnPlusMain

void mainPlustHeaderCallAndReturnPlusMain() {
  int i = 0;
  i++;
  do_something(i);
  causeDivByZeroInMain2(i);
  i++;
}
开发者ID:mspertus,项目名称:clang,代码行数:7,代码来源:report-issues-within-main-file.cpp

示例14: main

main() 
{
	int s, t;
	if ((s = establish(PORTNUM)) < 0) 
	{													 				/* plug in the phone */
		perror("establish");
		exit(1);
	} 
																		/* how a concurrent server looks like */
	for (;;) 
	{																	/* loop for phone calls */
		if ((t= get_connection(s)) < 0) 
		{																/* get a connection */
			perror("accept"); 											/* bad */
			exit(1);	
		}
		switch( fork() ) 
		{																/* try to handle connection */
			case -1 : 													/* bad news. scream and die */
				perror("fork");
				close(s);
				close(t);
				exit(1);
			case 0 : 													/* we're the child, do something */
				close(s);
				do_something(t);
				close(t);
				exit(0);
			default : 													/* we're the parent so look for */
				close(t); 												/* another connection */
				continue;
		}
	}
}														 				/* end of main */
开发者ID:i-cohen,项目名称:cs410-a3,代码行数:34,代码来源:matta-server.c

示例15: main

main(int argc, char* argv[],char ** environ)
{
      int child_proc_number = MAX_CHILD_NUMBER; 
      int i, ch; 
      pid_t  child_pid; 
      pid_t pid[10]={0};
     if (argc > 1)
     {
         child_proc_number = atoi(argv[1]); 
         child_proc_number= (child_proc_number > 10) ? 10 :
                                                    child_proc_number;
     } 
    for (i=0; i<child_proc_number; i++) {
        child_pid=fork();
        switch(child_pid){
          case -1:exit(1);

          case 0:proc_number=i;
                 do_something();
                 exit(1);
          default:pid[i]=child_pid;break;
        
      }
    }
      /* 让用户选择杀死进程,数字表示杀死该进程,q退出 */
   while ((ch = getchar()) != 'q'){ 
        if (isdigit(ch)){
                 kill(pid[ch-'0'],SIGTERM);
                 wait();
        }
   }
   kill(0,SIGTERM);
   return;
}
开发者ID:heyuhang,项目名称:linuxC,代码行数:34,代码来源:test01.c


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