Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
V

vczh_toys

> 编程语言
Open source

This repository contains vczh's toys for black magic codes or experiments

1.1K stars0 likes0 views
WebsiteGitHub

About

This repository contains vczh's toys for black magic codes or experiments

vczh_toys

This repository contains vczh's toys for black magic codes or experiments:

  • garbage collection library for C++11
  • multiple dimentional array for C++11
  • linq for C++11 and STL
  • Y function for writing recursive lambda expression

###./CppGarbageCollection ######// garbage collection library for C++

cpp
#include "gc_ptr.h"

using namespace vczh;

class Node : ENABLE_GC
{
public:
    gc_ptr next;
};

int main()
{
    gc_start(0x00100000, 0x00500000);
    {
        auto x = make_gc();
        auto y = make_gc();
        x->next = y;
        y->next = x;
        // static_gc_cast and dynamic_gc_cast is waiting for you who like doing pointer conversion
    }
    gc_force_collect(); // will search and delete x and y here
    gc_stop(); // will call gc_force_collect()
}

###./CppMultiDimentionArray ######// multiple dimentional array for C++

cpp
#include "array.h"

using namespace vczh;

int main()
{
	// int x[3][4][5]; but the lengths can be non-constant expressions
	array x((array_sizes(), 3, 4, 5));
	// first way to do x[1][2][3] = 10;
	x[1][2][3] = 10;
	// second way to do x[1][2][3] = 10;
	array_ref x1 = x[1];
	array_ref x2 = x1[2];
	int& x3 = x2[3];
	x3 = 10;
    return 0;
}

###./CppLinq ######// linq for C++11 and STL

cpp
#include "linq.h"
#include 

using namespace std;
using namespace vczh;

int main()
{
	{
		// calculate sum of squares of odd numbers
		int xs[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
		int sum = from(xs)
			.where([](int x){return x % 2 == 1; })
			.select([](int x){return x * x; })
			.sum();
		// prints 165
		cout >
			cout 
			cout 

using namespace std;
using namespace vczh;

int main()
{
	auto fib = Y([](function fib, int i)
	{
		return i < 2 ? 1 : fib(i - 1) + fib(i - 2);
	});

	for (int i = 0; i < 10; i++)
	{
		cout << fib(i) << ' ';
	}
	cout << endl;
}

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言