Example #1
0
void test_join_lambda() {
    {
        value1 = 0;
        value2 = "";
        int i = 3;
        std::string abc("abc");
        boost::fibers::fiber f(
                boost::fibers::launch::dispatch, [i,abc]() {
                    value1 = i;
                    value2 = abc;
                });
        f.join();
        BOOST_CHECK_EQUAL( value1, 3);
        BOOST_CHECK_EQUAL( value2, "abc");
    }
    {
        value1 = 0;
        value2 = "";
        int i = 3;
        std::string abc("abc");
        boost::fibers::fiber f(
                boost::fibers::launch::dispatch, [](int i, std::string const& abc) {
                    value1 = i;
                    value2 = abc;
                },
                i, abc);
        f.join();
        BOOST_CHECK_EQUAL( value1, 3);
        BOOST_CHECK_EQUAL( value2, "abc");
    }
}
Example #2
0
void test_join_bind() {
    {
        value1 = 0;
        value2 = "";
        int i = 3;
        std::string abc("abc");
        boost::fibers::fiber f(
            boost::fibers::launch::dispatch, std::bind(
                [i,abc]() {
                    value1 = i;
                    value2 = abc;
                }
            ));
        f.join();
        BOOST_CHECK_EQUAL( value1, 3);
        BOOST_CHECK_EQUAL( value2, "abc");
    }
    {
        value1 = 0;
        value2 = "";
        std::string abc("abc");
        boost::fibers::fiber f(
            boost::fibers::launch::dispatch, std::bind(
                [](std::string & str) {
                    value1 = 3;
                    value2 = str;
                },
                abc
            ));
        f.join();
        BOOST_CHECK_EQUAL( value1, 3);
        BOOST_CHECK_EQUAL( value2, "abc");
    }
    {
        value1 = 0;
        value2 = "";
        std::string abc("abc");
        boost::fibers::fiber f(
            boost::fibers::launch::dispatch, std::bind(
                []( std::string & str) {
                    value1 = 3;
                    value2 = str;
                },
                std::placeholders::_1
            ),
            std::ref( abc) );
        f.join();
        BOOST_CHECK_EQUAL( value1, 3);
        BOOST_CHECK_EQUAL( value2, "abc");
    }
}
Example #3
0
int main()
{
	std::vector<std::string> vec;
	//在顺序容器中添加元素
	std::string text;
	while(std::cin >> text) {
		if(text == "exit")
			break;
		vec.push_back(text);
	}

	//在指定位置插入
	std::string abc("abc");
	vec.insert(vec.begin(), abc);
	vec.insert(vec.begin() + 2, "xxx");

	//删除元素
	vec.erase(vec.end());

	std::cout << "vec.size = " << vec.size() << ", vec empty ? " << vec.empty() << std::endl;
	std::cout << "vec.first = " << *vec.begin() << ", vec.last = " << *(vec.end() - 1) << std::endl;

	//插入一段元素
	std::vector<std::string> vec2;
	vec2.insert(vec2.begin(), vec.begin(), vec.end());

	//遍历
	std::vector<std::string>::iterator it;
	for(it = vec2.begin(); it < vec2.end(); it++) {
		std::cout <<  "item " << it - vec2.begin() << " : " << " : " << *it << std::endl;
	}

}
Example #4
0
void abc_test() {
    concat<char> str;
    abc(&str);
    char curr = 'a';
    while (str.ready()) {
        assert(str.get() == curr++);
    }
    assert(str.empty());
    assert(str.depleted());
    assert(str.closed());
}
Example #5
0
int
main(int argc, char *argv[])
{
    void xyz(void), abc(void);

    printf("main() calling xyz()\n");
    xyz();

    abc();

    exit(EXIT_SUCCESS);
}
int main() {
	try {
		Sudoku abc(std::cin);
		abc[0][0].field=Sudoku::Number::ONE;
		for (int i=0; i<9; i++) {
			for (int j=0; j<9; j++) {
				std::cout<<abc[i][j].field<<" ";
			}
			std::cout<<"\n";
		}
	} catch (std::exception& e) {
		std::cout<<e.what();
	}

	return 0;
}
Example #7
0
void principal() {
    int i;
    int j;
    bool d;
    bool e;
    bool f;
    scanf("%d",&i);
    j = abc(j, d);
    if(i > 10) {
        printf("%d",i);
    }
    else {
        printf("%c",'<'      );
    }
    while (i < 10) {
        printf("%c",'<'      );
        i = i + 1;
    }
}
Example #8
0
int main(int argc, char *argv[]) {
    void xyz(void);
    void xyz_old(void), xyz_new(void);
    void abc(void);

    printf("Calling abc()\n");
    abc();

    printf("Calling xyz()\n");
    xyz();

    printf("Calling xyz_new()\n");
    xyz_new();

    printf("Calling xyz_old()\n");
    xyz_old();

    //xxx();

    exit(0);
}
Example #9
0
	// cross product
	abc cross( const abc & z ) const {
		return abc( b * z.c - c * z.b, c * z.a - a * z.c, a * z.b - b * z.a );
	}
Example #10
0
a::b c()
{
mapped_file_source abc((int) CW1A(sTemp));
mapped_file_source abc((int) ::CW2A(sTemp));
mapped_file_source abc((int) A::CW3A(sTemp));
}
void prog10()
{
    abc(10.0);
    abc(10.1);
}