summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt6
-rw-r--r--include/stc/carc.h4
-rw-r--r--include/stc/carr2.h4
-rw-r--r--include/stc/carr3.h4
-rw-r--r--include/stc/cbox.h4
-rw-r--r--include/stc/cdeq.h4
-rw-r--r--include/stc/clist.h4
-rw-r--r--include/stc/cmap.h4
-rw-r--r--include/stc/cpque.h4
-rw-r--r--include/stc/csmap.h4
-rw-r--r--include/stc/cstack.h4
-rw-r--r--include/stc/cvec.h6
-rw-r--r--include/stc/priv/template.h (renamed from include/stc/template.h)0
-rw-r--r--misc/benchmarks/build_all.sh (renamed from benchmarks/build_all.sh)2
-rw-r--r--misc/benchmarks/external/ankerl/robin_hood.h (renamed from benchmarks/external/ankerl/robin_hood.h)0
-rw-r--r--misc/benchmarks/external/ankerl/unordered_dense.h (renamed from benchmarks/external/ankerl/unordered_dense.h)0
-rw-r--r--misc/benchmarks/external/emhash/hash_table7.hpp (renamed from benchmarks/external/emhash/hash_table7.hpp)0
-rw-r--r--misc/benchmarks/external/khash.h (renamed from benchmarks/external/khash.h)0
-rw-r--r--misc/benchmarks/external/skarupke/flat_hash_map.hpp (renamed from benchmarks/external/skarupke/flat_hash_map.hpp)0
-rw-r--r--misc/benchmarks/external/tsl/robin_growth_policy.h (renamed from benchmarks/external/tsl/robin_growth_policy.h)0
-rw-r--r--misc/benchmarks/external/tsl/robin_hash.h (renamed from benchmarks/external/tsl/robin_hash.h)0
-rw-r--r--misc/benchmarks/external/tsl/robin_map.h (renamed from benchmarks/external/tsl/robin_map.h)0
-rw-r--r--misc/benchmarks/external/update.sh (renamed from benchmarks/external/update.sh)0
-rw-r--r--misc/benchmarks/misc/cbits_benchmark.cpp (renamed from benchmarks/misc/cbits_benchmark.cpp)0
-rw-r--r--misc/benchmarks/misc/names.txt (renamed from benchmarks/misc/names.txt)0
-rw-r--r--misc/benchmarks/misc/prng_bench.cpp (renamed from benchmarks/misc/prng_bench.cpp)0
-rw-r--r--misc/benchmarks/misc/rust_cmap.c (renamed from benchmarks/misc/rust_cmap.c)0
-rw-r--r--misc/benchmarks/misc/rust_hashmap.rs (renamed from benchmarks/misc/rust_hashmap.rs)0
-rw-r--r--misc/benchmarks/misc/sso_bench.cpp (renamed from benchmarks/misc/sso_bench.cpp)0
-rw-r--r--misc/benchmarks/misc/string_bench_STC.cpp (renamed from benchmarks/misc/string_bench_STC.cpp)0
-rw-r--r--misc/benchmarks/misc/string_bench_STD.cpp (renamed from benchmarks/misc/string_bench_STD.cpp)0
-rw-r--r--misc/benchmarks/picobench/picobench.hpp (renamed from benchmarks/picobench/picobench.hpp)0
-rw-r--r--misc/benchmarks/picobench/picobench_cmap.cpp (renamed from benchmarks/picobench/picobench_cmap.cpp)0
-rw-r--r--misc/benchmarks/picobench/picobench_csmap.cpp (renamed from benchmarks/picobench/picobench_csmap.cpp)0
-rw-r--r--misc/benchmarks/pics/benchmark.gif (renamed from benchmarks/pics/benchmark.gif)bin160087 -> 160087 bytes
-rw-r--r--misc/benchmarks/plotbench/cdeq_benchmark.cpp (renamed from benchmarks/plotbench/cdeq_benchmark.cpp)0
-rw-r--r--misc/benchmarks/plotbench/clist_benchmark.cpp (renamed from benchmarks/plotbench/clist_benchmark.cpp)0
-rw-r--r--misc/benchmarks/plotbench/cmap_benchmark.cpp (renamed from benchmarks/plotbench/cmap_benchmark.cpp)0
-rw-r--r--misc/benchmarks/plotbench/cpque_benchmark.cpp (renamed from benchmarks/plotbench/cpque_benchmark.cpp)0
-rw-r--r--misc/benchmarks/plotbench/csmap_benchmark.cpp (renamed from benchmarks/plotbench/csmap_benchmark.cpp)0
-rw-r--r--misc/benchmarks/plotbench/cvec_benchmark.cpp (renamed from benchmarks/plotbench/cvec_benchmark.cpp)0
-rw-r--r--misc/benchmarks/plotbench/plot.py (renamed from benchmarks/plotbench/plot.py)0
-rw-r--r--misc/benchmarks/plotbench/run_all.bat (renamed from benchmarks/plotbench/run_all.bat)0
-rw-r--r--misc/benchmarks/plotbench/run_all.sh (renamed from benchmarks/plotbench/run_all.sh)0
-rw-r--r--misc/benchmarks/plotbench/run_clang.sh (renamed from benchmarks/plotbench/run_clang.sh)0
-rw-r--r--misc/benchmarks/plotbench/run_gcc.sh (renamed from benchmarks/plotbench/run_gcc.sh)0
-rw-r--r--misc/benchmarks/plotbench/run_vc.bat (renamed from benchmarks/plotbench/run_vc.bat)0
-rw-r--r--misc/benchmarks/shootout_hashmaps.cpp (renamed from benchmarks/shootout_hashmaps.cpp)0
-rw-r--r--misc/examples/README.md (renamed from examples/README.md)0
-rw-r--r--misc/examples/arc_containers.c (renamed from examples/arc_containers.c)0
-rw-r--r--misc/examples/arc_demo.c (renamed from examples/arc_demo.c)0
-rw-r--r--misc/examples/arcvec_erase.c (renamed from examples/arcvec_erase.c)0
-rw-r--r--misc/examples/astar.c (renamed from examples/astar.c)0
-rw-r--r--misc/examples/birthday.c (renamed from examples/birthday.c)0
-rw-r--r--misc/examples/bits.c (renamed from examples/bits.c)0
-rw-r--r--misc/examples/bits2.c (renamed from examples/bits2.c)0
-rw-r--r--misc/examples/books.c (renamed from examples/books.c)0
-rw-r--r--misc/examples/box.c (renamed from examples/box.c)0
-rw-r--r--misc/examples/box2.c (renamed from examples/box2.c)0
-rw-r--r--misc/examples/city.c (renamed from examples/city.c)0
-rw-r--r--misc/examples/complex.c (renamed from examples/complex.c)0
-rw-r--r--misc/examples/convert.c (renamed from examples/convert.c)0
-rw-r--r--misc/examples/cpque.c (renamed from examples/cpque.c)0
-rw-r--r--misc/examples/csmap_erase.c (renamed from examples/csmap_erase.c)0
-rw-r--r--misc/examples/csmap_find.c (renamed from examples/csmap_find.c)0
-rw-r--r--misc/examples/csmap_insert.c (renamed from examples/csmap_insert.c)0
-rw-r--r--misc/examples/csset_erase.c (renamed from examples/csset_erase.c)0
-rw-r--r--misc/examples/cstr_match.c (renamed from examples/cstr_match.c)0
-rw-r--r--misc/examples/demos.c (renamed from examples/demos.c)0
-rw-r--r--misc/examples/forfilter.c (renamed from examples/forfilter.c)0
-rw-r--r--misc/examples/forloops.c (renamed from examples/forloops.c)0
-rw-r--r--misc/examples/gauss1.c (renamed from examples/gauss1.c)0
-rw-r--r--misc/examples/gauss2.c (renamed from examples/gauss2.c)0
-rw-r--r--misc/examples/hashmap.c (renamed from examples/hashmap.c)0
-rw-r--r--misc/examples/inits.c (renamed from examples/inits.c)0
-rw-r--r--misc/examples/intrusive.c (renamed from examples/intrusive.c)0
-rw-r--r--misc/examples/list.c (renamed from examples/list.c)0
-rw-r--r--misc/examples/list_erase.c (renamed from examples/list_erase.c)0
-rw-r--r--misc/examples/list_splice.c (renamed from examples/list_splice.c)0
-rw-r--r--misc/examples/lower_bound.c (renamed from examples/lower_bound.c)0
-rwxr-xr-xmisc/examples/make.sh (renamed from examples/make.sh)0
-rw-r--r--misc/examples/mapmap.c (renamed from examples/mapmap.c)0
-rw-r--r--misc/examples/mmap.c (renamed from examples/mmap.c)0
-rw-r--r--misc/examples/multimap.c (renamed from examples/multimap.c)0
-rw-r--r--misc/examples/music_arc.c (renamed from examples/music_arc.c)0
-rw-r--r--misc/examples/new_arr.c (renamed from examples/new_arr.c)0
-rw-r--r--misc/examples/new_deq.c (renamed from examples/new_deq.c)0
-rw-r--r--misc/examples/new_list.c (renamed from examples/new_list.c)0
-rw-r--r--misc/examples/new_map.c (renamed from examples/new_map.c)0
-rw-r--r--misc/examples/new_pque.c (renamed from examples/new_pque.c)0
-rw-r--r--misc/examples/new_queue.c (renamed from examples/new_queue.c)0
-rw-r--r--misc/examples/new_smap.c (renamed from examples/new_smap.c)0
-rw-r--r--misc/examples/new_sptr.c (renamed from examples/new_sptr.c)0
-rw-r--r--misc/examples/new_vec.c (renamed from examples/new_vec.c)0
-rw-r--r--misc/examples/person_arc.c (renamed from examples/person_arc.c)0
-rw-r--r--misc/examples/phonebook.c (renamed from examples/phonebook.c)0
-rw-r--r--misc/examples/prime.c (renamed from examples/prime.c)0
-rw-r--r--misc/examples/priority.c (renamed from examples/priority.c)0
-rw-r--r--misc/examples/queue.c (renamed from examples/queue.c)0
-rw-r--r--misc/examples/random.c (renamed from examples/random.c)0
-rw-r--r--misc/examples/rawptr_elements.c (renamed from examples/rawptr_elements.c)0
-rw-r--r--misc/examples/read.c (renamed from examples/read.c)0
-rw-r--r--misc/examples/regex1.c (renamed from examples/regex1.c)0
-rw-r--r--misc/examples/regex2.c (renamed from examples/regex2.c)0
-rw-r--r--misc/examples/regex_match.c (renamed from examples/regex_match.c)0
-rw-r--r--misc/examples/regex_replace.c (renamed from examples/regex_replace.c)0
-rw-r--r--misc/examples/replace.c (renamed from examples/replace.c)0
-rw-r--r--misc/examples/shape.c (renamed from examples/shape.c)0
-rw-r--r--misc/examples/shape.cpp (renamed from examples/shape.cpp)0
-rw-r--r--misc/examples/sidebyside.cpp (renamed from examples/sidebyside.cpp)0
-rw-r--r--misc/examples/sorted_map.c (renamed from examples/sorted_map.c)0
-rw-r--r--misc/examples/splitstr.c (renamed from examples/splitstr.c)0
-rw-r--r--misc/examples/sso_map.c (renamed from examples/sso_map.c)0
-rw-r--r--misc/examples/sso_substr.c (renamed from examples/sso_substr.c)0
-rw-r--r--misc/examples/stack.c (renamed from examples/stack.c)0
-rw-r--r--misc/examples/sview_split.c (renamed from examples/sview_split.c)0
-rw-r--r--misc/examples/unordered_set.c (renamed from examples/unordered_set.c)0
-rw-r--r--misc/examples/utf8replace_c.c (renamed from examples/utf8replace_c.c)0
-rw-r--r--misc/examples/utf8replace_rs.rs (renamed from examples/utf8replace_rs.rs)0
-rw-r--r--misc/examples/vikings.c (renamed from examples/vikings.c)0
-rw-r--r--misc/examples/words.c (renamed from examples/words.c)0
-rw-r--r--misc/include/alt/csmap.h (renamed from include/stc/alt/csmap.h)4
-rw-r--r--misc/include/alt/cstr.h (renamed from include/stc/alt/cstr.h)0
-rw-r--r--misc/include/fmt.h253
-rw-r--r--misc/include/stctest.h (renamed from include/stc/stctest.h)0
-rw-r--r--misc/tests/cregex_test.c (renamed from tests/cregex_test.c)0
126 files changed, 282 insertions, 29 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1a38453f..2f54a7f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,8 +12,8 @@ add_executable(checkauto ${FLEX_checkauto_OUTPUTS})
include(CTest)
if(BUILD_TESTING)
- file(GLOB examples examples/*.c)
- foreach(file IN LISTS examples)
+ file(GLOB misc/examples misc/examples/*.c)
+ foreach(file IN LISTS misc/examples)
get_filename_component(name "${file}" NAME_WE)
add_executable(${name} ${file})
target_compile_options(${name} PRIVATE "-pthread")
@@ -24,7 +24,7 @@ if(BUILD_TESTING)
add_test(NAME ${name} COMMAND ${name})
endforeach()
# foreach(name IN ITEMS cdeq clist cmap csmap cvec)
- # add_executable(${name} benchmarks/plotbench/${name}_benchmark.cpp)
+ # add_executable(${name} misc/benchmarks/plotbench/${name}_benchmark.cpp)
# target_link_libraries(${name} PRIVATE stc m)
# add_test(NAME ${name} COMMAND ${name})
# endforeach()
diff --git a/include/stc/carc.h b/include/stc/carc.h
index 509bc595..22453f1d 100644
--- a/include/stc/carc.h
+++ b/include/stc/carc.h
@@ -78,7 +78,7 @@ int main() {
#ifndef _i_prefix
#define _i_prefix carc_
#endif
-#include "template.h"
+#include "priv/template.h"
typedef i_keyraw _cx_raw;
#if !c_option(c_no_atomic)
@@ -201,4 +201,4 @@ STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* x)
#undef _i_atomic_inc
#undef _i_atomic_dec_and_test
-#include "template.h"
+#include "priv/template.h"
diff --git a/include/stc/carr2.h b/include/stc/carr2.h
index 4a12c2e3..89ae9b77 100644
--- a/include/stc/carr2.h
+++ b/include/stc/carr2.h
@@ -56,7 +56,7 @@ int main() {
#ifndef _i_prefix
#define _i_prefix carr2_
#endif
-#include "template.h"
+#include "priv/template.h"
#if !c_option(c_is_forward)
_cx_deftypes(_c_carr2_types, _cx_self, i_key);
#endif
@@ -149,4 +149,4 @@ STC_DEF void _cx_memb(_drop)(_cx_self* self) {
}
#endif
-#include "template.h"
+#include "priv/template.h"
diff --git a/include/stc/carr3.h b/include/stc/carr3.h
index c22536cb..d167dd69 100644
--- a/include/stc/carr3.h
+++ b/include/stc/carr3.h
@@ -57,7 +57,7 @@ int main() {
#ifndef _i_prefix
#define _i_prefix carr3_
#endif
-#include "template.h"
+#include "priv/template.h"
#if !c_option(c_is_forward)
_cx_deftypes(_c_carr3_types, _cx_self, i_key);
@@ -154,4 +154,4 @@ STC_DEF void _cx_memb(_drop)(_cx_self* self) {
}
#endif
-#include "template.h"
+#include "priv/template.h"
diff --git a/include/stc/cbox.h b/include/stc/cbox.h
index 4cbd5f84..bcb1b275 100644
--- a/include/stc/cbox.h
+++ b/include/stc/cbox.h
@@ -70,7 +70,7 @@ int main() {
#ifndef _i_prefix
#define _i_prefix cbox_
#endif
-#include "template.h"
+#include "priv/template.h"
typedef i_keyraw _cx_raw;
#if !c_option(c_is_forward)
@@ -174,4 +174,4 @@ STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* x)
{ _cx_raw rx = i_keyto(x->get); return i_hash(&rx); }
#endif
-#include "template.h"
+#include "priv/template.h"
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index a8a704b4..9416d5b2 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -34,7 +34,7 @@
#ifndef _i_prefix
#define _i_prefix cdeq_
#endif
-#include "template.h"
+#include "priv/template.h"
#if !c_option(c_is_forward)
_cx_deftypes(_c_cdeq_types, _cx_self, i_key);
@@ -425,5 +425,5 @@ _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) {
#endif // !c_no_cmp
#endif // !_i_queue
#endif // IMPLEMENTATION
-#include "template.h"
+#include "priv/template.h"
#define CDEQ_H_INCLUDED
diff --git a/include/stc/clist.h b/include/stc/clist.h
index 8b96eabf..1ace1dac 100644
--- a/include/stc/clist.h
+++ b/include/stc/clist.h
@@ -83,7 +83,7 @@ _c_clist_complete_types(clist_VOID, dummy);
#ifndef _i_prefix
#define _i_prefix clist_
#endif
-#include "template.h"
+#include "priv/template.h"
#if !c_option(c_is_forward)
_cx_deftypes(_c_clist_types, _cx_self, i_key);
@@ -442,4 +442,4 @@ _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) {
#endif // !c_no_cmp
#endif // i_implement
#define CLIST_H_INCLUDED
-#include "template.h"
+#include "priv/template.h"
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index b0793ce5..11edf127 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -73,7 +73,7 @@ typedef struct { size_t idx; uint8_t hx; } chash_bucket_t;
#ifndef i_max_load_factor
#define i_max_load_factor 0.85f
#endif
-#include "template.h"
+#include "priv/template.h"
#ifndef i_hash_functor
#define i_hash_functor(self, x) i_hash(x)
#endif
@@ -450,4 +450,4 @@ _cx_memb(_erase_entry)(_cx_self* self, _cx_value* _val) {
#undef _i_MAP_ONLY
#undef _i_SET_ONLY
#define CMAP_H_INCLUDED
-#include "template.h"
+#include "priv/template.h"
diff --git a/include/stc/cpque.h b/include/stc/cpque.h
index 9cf4b167..c1e7c13b 100644
--- a/include/stc/cpque.h
+++ b/include/stc/cpque.h
@@ -31,7 +31,7 @@
#define _i_prefix cpque_
#endif
-#include "template.h"
+#include "priv/template.h"
#ifndef i_less_functor
#define i_less_functor(self, x, y) i_less(x, y)
#endif
@@ -158,4 +158,4 @@ _cx_memb(_push)(_cx_self* self, _cx_value value) {
#endif
#define CPQUE_H_INCLUDED
#undef i_less_functor
-#include "template.h"
+#include "priv/template.h"
diff --git a/include/stc/csmap.h b/include/stc/csmap.h
index 5c73294e..f651db00 100644
--- a/include/stc/csmap.h
+++ b/include/stc/csmap.h
@@ -73,7 +73,7 @@ int main(void) {
#define _i_SET_ONLY c_false
#define _i_keyref(vp) (&(vp)->first)
#endif
-#include "template.h"
+#include "priv/template.h"
#ifndef i_cmp_functor
#define i_cmp_functor(self, x, y) i_cmp(x, y)
#endif
@@ -575,5 +575,5 @@ _cx_memb(_drop)(_cx_self* self) {
#undef _i_MAP_ONLY
#undef _i_SET_ONLY
#define CSMAP_H_INCLUDED
-#include "template.h"
+#include "priv/template.h"
#endif // !STC_CSMAP_V1
diff --git a/include/stc/cstack.h b/include/stc/cstack.h
index 23778e3c..73d0e2e1 100644
--- a/include/stc/cstack.h
+++ b/include/stc/cstack.h
@@ -31,7 +31,7 @@
#ifndef _i_prefix
#define _i_prefix cstack_
#endif
-#include "template.h"
+#include "priv/template.h"
#if !c_option(c_is_forward)
#ifdef i_capacity
@@ -183,4 +183,4 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it)
STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t n)
{ if ((it.ref += n) >= it.end) it.ref = NULL ; return it; }
-#include "template.h"
+#include "priv/template.h"
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index ae6e452c..5eaefa04 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -71,7 +71,7 @@ int main() {
#ifndef _i_prefix
#define _i_prefix cvec_
#endif
-#include "template.h"
+#include "priv/template.h"
#if !c_option(c_is_forward)
_cx_deftypes(_c_cvec_types, _cx_self, i_key);
@@ -256,7 +256,7 @@ _cx_memb(_sort)(_cx_self* self) {
STC_DEF _cx_self
_cx_memb(_init)(void) {
- return (_cx_self){NULL};
+ return c_INIT(_cx_self){NULL};
}
STC_DEF void
@@ -420,4 +420,4 @@ _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) {
#endif // !c_no_cmp
#endif // i_implement
#define CVEC_H_INCLUDED
-#include "template.h"
+#include "priv/template.h"
diff --git a/include/stc/template.h b/include/stc/priv/template.h
index b7583e82..b7583e82 100644
--- a/include/stc/template.h
+++ b/include/stc/priv/template.h
diff --git a/benchmarks/build_all.sh b/misc/benchmarks/build_all.sh
index 657f8cbf..54340998 100644
--- a/benchmarks/build_all.sh
+++ b/misc/benchmarks/build_all.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-cc='g++ -I../include -s -O3 -Wall -pedantic -x c++ -std=c++20'
+cc='g++ -I../../include -s -O3 -Wall -pedantic -x c++ -std=c++20'
#cc='clang++ -I../include -s -O3 -Wall -pedantic -x c++ -std=c++20'
#cc='cl -nologo -I../include -O2 -TP -EHsc -std:c++20'
run=0
diff --git a/benchmarks/external/ankerl/robin_hood.h b/misc/benchmarks/external/ankerl/robin_hood.h
index 0af031f5..0af031f5 100644
--- a/benchmarks/external/ankerl/robin_hood.h
+++ b/misc/benchmarks/external/ankerl/robin_hood.h
diff --git a/benchmarks/external/ankerl/unordered_dense.h b/misc/benchmarks/external/ankerl/unordered_dense.h
index ff902ad4..ff902ad4 100644
--- a/benchmarks/external/ankerl/unordered_dense.h
+++ b/misc/benchmarks/external/ankerl/unordered_dense.h
diff --git a/benchmarks/external/emhash/hash_table7.hpp b/misc/benchmarks/external/emhash/hash_table7.hpp
index fdc33fe1..fdc33fe1 100644
--- a/benchmarks/external/emhash/hash_table7.hpp
+++ b/misc/benchmarks/external/emhash/hash_table7.hpp
diff --git a/benchmarks/external/khash.h b/misc/benchmarks/external/khash.h
index 61dabc4d..61dabc4d 100644
--- a/benchmarks/external/khash.h
+++ b/misc/benchmarks/external/khash.h
diff --git a/benchmarks/external/skarupke/flat_hash_map.hpp b/misc/benchmarks/external/skarupke/flat_hash_map.hpp
index a8723ee8..a8723ee8 100644
--- a/benchmarks/external/skarupke/flat_hash_map.hpp
+++ b/misc/benchmarks/external/skarupke/flat_hash_map.hpp
diff --git a/benchmarks/external/tsl/robin_growth_policy.h b/misc/benchmarks/external/tsl/robin_growth_policy.h
index eba8cdfa..eba8cdfa 100644
--- a/benchmarks/external/tsl/robin_growth_policy.h
+++ b/misc/benchmarks/external/tsl/robin_growth_policy.h
diff --git a/benchmarks/external/tsl/robin_hash.h b/misc/benchmarks/external/tsl/robin_hash.h
index 89c7c96f..89c7c96f 100644
--- a/benchmarks/external/tsl/robin_hash.h
+++ b/misc/benchmarks/external/tsl/robin_hash.h
diff --git a/benchmarks/external/tsl/robin_map.h b/misc/benchmarks/external/tsl/robin_map.h
index aeb354c3..aeb354c3 100644
--- a/benchmarks/external/tsl/robin_map.h
+++ b/misc/benchmarks/external/tsl/robin_map.h
diff --git a/benchmarks/external/update.sh b/misc/benchmarks/external/update.sh
index 45b472b1..45b472b1 100644
--- a/benchmarks/external/update.sh
+++ b/misc/benchmarks/external/update.sh
diff --git a/benchmarks/misc/cbits_benchmark.cpp b/misc/benchmarks/misc/cbits_benchmark.cpp
index dd709db1..dd709db1 100644
--- a/benchmarks/misc/cbits_benchmark.cpp
+++ b/misc/benchmarks/misc/cbits_benchmark.cpp
diff --git a/benchmarks/misc/names.txt b/misc/benchmarks/misc/names.txt
index 561acbbf..561acbbf 100644
--- a/benchmarks/misc/names.txt
+++ b/misc/benchmarks/misc/names.txt
diff --git a/benchmarks/misc/prng_bench.cpp b/misc/benchmarks/misc/prng_bench.cpp
index 6f4e0e47..6f4e0e47 100644
--- a/benchmarks/misc/prng_bench.cpp
+++ b/misc/benchmarks/misc/prng_bench.cpp
diff --git a/benchmarks/misc/rust_cmap.c b/misc/benchmarks/misc/rust_cmap.c
index 83b7dd19..83b7dd19 100644
--- a/benchmarks/misc/rust_cmap.c
+++ b/misc/benchmarks/misc/rust_cmap.c
diff --git a/benchmarks/misc/rust_hashmap.rs b/misc/benchmarks/misc/rust_hashmap.rs
index 5394a7c3..5394a7c3 100644
--- a/benchmarks/misc/rust_hashmap.rs
+++ b/misc/benchmarks/misc/rust_hashmap.rs
diff --git a/benchmarks/misc/sso_bench.cpp b/misc/benchmarks/misc/sso_bench.cpp
index 0fffef7a..0fffef7a 100644
--- a/benchmarks/misc/sso_bench.cpp
+++ b/misc/benchmarks/misc/sso_bench.cpp
diff --git a/benchmarks/misc/string_bench_STC.cpp b/misc/benchmarks/misc/string_bench_STC.cpp
index ae8e4c38..ae8e4c38 100644
--- a/benchmarks/misc/string_bench_STC.cpp
+++ b/misc/benchmarks/misc/string_bench_STC.cpp
diff --git a/benchmarks/misc/string_bench_STD.cpp b/misc/benchmarks/misc/string_bench_STD.cpp
index 8bb87937..8bb87937 100644
--- a/benchmarks/misc/string_bench_STD.cpp
+++ b/misc/benchmarks/misc/string_bench_STD.cpp
diff --git a/benchmarks/picobench/picobench.hpp b/misc/benchmarks/picobench/picobench.hpp
index 2e4541e0..2e4541e0 100644
--- a/benchmarks/picobench/picobench.hpp
+++ b/misc/benchmarks/picobench/picobench.hpp
diff --git a/benchmarks/picobench/picobench_cmap.cpp b/misc/benchmarks/picobench/picobench_cmap.cpp
index 3ffba5b9..3ffba5b9 100644
--- a/benchmarks/picobench/picobench_cmap.cpp
+++ b/misc/benchmarks/picobench/picobench_cmap.cpp
diff --git a/benchmarks/picobench/picobench_csmap.cpp b/misc/benchmarks/picobench/picobench_csmap.cpp
index 5caab6cc..5caab6cc 100644
--- a/benchmarks/picobench/picobench_csmap.cpp
+++ b/misc/benchmarks/picobench/picobench_csmap.cpp
diff --git a/benchmarks/pics/benchmark.gif b/misc/benchmarks/pics/benchmark.gif
index 90f47fff..90f47fff 100644
--- a/benchmarks/pics/benchmark.gif
+++ b/misc/benchmarks/pics/benchmark.gif
Binary files differ
diff --git a/benchmarks/plotbench/cdeq_benchmark.cpp b/misc/benchmarks/plotbench/cdeq_benchmark.cpp
index 1259cc07..1259cc07 100644
--- a/benchmarks/plotbench/cdeq_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cdeq_benchmark.cpp
diff --git a/benchmarks/plotbench/clist_benchmark.cpp b/misc/benchmarks/plotbench/clist_benchmark.cpp
index 04c8e8cd..04c8e8cd 100644
--- a/benchmarks/plotbench/clist_benchmark.cpp
+++ b/misc/benchmarks/plotbench/clist_benchmark.cpp
diff --git a/benchmarks/plotbench/cmap_benchmark.cpp b/misc/benchmarks/plotbench/cmap_benchmark.cpp
index 7a8f29d2..7a8f29d2 100644
--- a/benchmarks/plotbench/cmap_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cmap_benchmark.cpp
diff --git a/benchmarks/plotbench/cpque_benchmark.cpp b/misc/benchmarks/plotbench/cpque_benchmark.cpp
index a729c09f..a729c09f 100644
--- a/benchmarks/plotbench/cpque_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cpque_benchmark.cpp
diff --git a/benchmarks/plotbench/csmap_benchmark.cpp b/misc/benchmarks/plotbench/csmap_benchmark.cpp
index 46bd695c..46bd695c 100644
--- a/benchmarks/plotbench/csmap_benchmark.cpp
+++ b/misc/benchmarks/plotbench/csmap_benchmark.cpp
diff --git a/benchmarks/plotbench/cvec_benchmark.cpp b/misc/benchmarks/plotbench/cvec_benchmark.cpp
index fe7e09fb..fe7e09fb 100644
--- a/benchmarks/plotbench/cvec_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cvec_benchmark.cpp
diff --git a/benchmarks/plotbench/plot.py b/misc/benchmarks/plotbench/plot.py
index fa538285..fa538285 100644
--- a/benchmarks/plotbench/plot.py
+++ b/misc/benchmarks/plotbench/plot.py
diff --git a/benchmarks/plotbench/run_all.bat b/misc/benchmarks/plotbench/run_all.bat
index 2edd0a1e..2edd0a1e 100644
--- a/benchmarks/plotbench/run_all.bat
+++ b/misc/benchmarks/plotbench/run_all.bat
diff --git a/benchmarks/plotbench/run_all.sh b/misc/benchmarks/plotbench/run_all.sh
index f15a5881..f15a5881 100644
--- a/benchmarks/plotbench/run_all.sh
+++ b/misc/benchmarks/plotbench/run_all.sh
diff --git a/benchmarks/plotbench/run_clang.sh b/misc/benchmarks/plotbench/run_clang.sh
index ae19486e..ae19486e 100644
--- a/benchmarks/plotbench/run_clang.sh
+++ b/misc/benchmarks/plotbench/run_clang.sh
diff --git a/benchmarks/plotbench/run_gcc.sh b/misc/benchmarks/plotbench/run_gcc.sh
index 6a6472c0..6a6472c0 100644
--- a/benchmarks/plotbench/run_gcc.sh
+++ b/misc/benchmarks/plotbench/run_gcc.sh
diff --git a/benchmarks/plotbench/run_vc.bat b/misc/benchmarks/plotbench/run_vc.bat
index 3dca925b..3dca925b 100644
--- a/benchmarks/plotbench/run_vc.bat
+++ b/misc/benchmarks/plotbench/run_vc.bat
diff --git a/benchmarks/shootout_hashmaps.cpp b/misc/benchmarks/shootout_hashmaps.cpp
index 78d7bce2..78d7bce2 100644
--- a/benchmarks/shootout_hashmaps.cpp
+++ b/misc/benchmarks/shootout_hashmaps.cpp
diff --git a/examples/README.md b/misc/examples/README.md
index 4c0aa763..4c0aa763 100644
--- a/examples/README.md
+++ b/misc/examples/README.md
diff --git a/examples/arc_containers.c b/misc/examples/arc_containers.c
index b577f2c8..b577f2c8 100644
--- a/examples/arc_containers.c
+++ b/misc/examples/arc_containers.c
diff --git a/examples/arc_demo.c b/misc/examples/arc_demo.c
index 087f90ac..087f90ac 100644
--- a/examples/arc_demo.c
+++ b/misc/examples/arc_demo.c
diff --git a/examples/arcvec_erase.c b/misc/examples/arcvec_erase.c
index c70d59d9..c70d59d9 100644
--- a/examples/arcvec_erase.c
+++ b/misc/examples/arcvec_erase.c
diff --git a/examples/astar.c b/misc/examples/astar.c
index d4a821f9..d4a821f9 100644
--- a/examples/astar.c
+++ b/misc/examples/astar.c
diff --git a/examples/birthday.c b/misc/examples/birthday.c
index 48b8ceaa..48b8ceaa 100644
--- a/examples/birthday.c
+++ b/misc/examples/birthday.c
diff --git a/examples/bits.c b/misc/examples/bits.c
index 82fd65ec..82fd65ec 100644
--- a/examples/bits.c
+++ b/misc/examples/bits.c
diff --git a/examples/bits2.c b/misc/examples/bits2.c
index 59e0b337..59e0b337 100644
--- a/examples/bits2.c
+++ b/misc/examples/bits2.c
diff --git a/examples/books.c b/misc/examples/books.c
index b6067d81..b6067d81 100644
--- a/examples/books.c
+++ b/misc/examples/books.c
diff --git a/examples/box.c b/misc/examples/box.c
index da13501f..da13501f 100644
--- a/examples/box.c
+++ b/misc/examples/box.c
diff --git a/examples/box2.c b/misc/examples/box2.c
index b9628eeb..b9628eeb 100644
--- a/examples/box2.c
+++ b/misc/examples/box2.c
diff --git a/examples/city.c b/misc/examples/city.c
index 8557c6cf..8557c6cf 100644
--- a/examples/city.c
+++ b/misc/examples/city.c
diff --git a/examples/complex.c b/misc/examples/complex.c
index dd2f951a..dd2f951a 100644
--- a/examples/complex.c
+++ b/misc/examples/complex.c
diff --git a/examples/convert.c b/misc/examples/convert.c
index 18be3c81..18be3c81 100644
--- a/examples/convert.c
+++ b/misc/examples/convert.c
diff --git a/examples/cpque.c b/misc/examples/cpque.c
index 7254b0f7..7254b0f7 100644
--- a/examples/cpque.c
+++ b/misc/examples/cpque.c
diff --git a/examples/csmap_erase.c b/misc/examples/csmap_erase.c
index 48d8ceef..48d8ceef 100644
--- a/examples/csmap_erase.c
+++ b/misc/examples/csmap_erase.c
diff --git a/examples/csmap_find.c b/misc/examples/csmap_find.c
index 3c507476..3c507476 100644
--- a/examples/csmap_find.c
+++ b/misc/examples/csmap_find.c
diff --git a/examples/csmap_insert.c b/misc/examples/csmap_insert.c
index 8f777fc6..8f777fc6 100644
--- a/examples/csmap_insert.c
+++ b/misc/examples/csmap_insert.c
diff --git a/examples/csset_erase.c b/misc/examples/csset_erase.c
index 33eb2163..33eb2163 100644
--- a/examples/csset_erase.c
+++ b/misc/examples/csset_erase.c
diff --git a/examples/cstr_match.c b/misc/examples/cstr_match.c
index 286ba505..286ba505 100644
--- a/examples/cstr_match.c
+++ b/misc/examples/cstr_match.c
diff --git a/examples/demos.c b/misc/examples/demos.c
index fc3771cb..fc3771cb 100644
--- a/examples/demos.c
+++ b/misc/examples/demos.c
diff --git a/examples/forfilter.c b/misc/examples/forfilter.c
index ba4dce7f..ba4dce7f 100644
--- a/examples/forfilter.c
+++ b/misc/examples/forfilter.c
diff --git a/examples/forloops.c b/misc/examples/forloops.c
index 2654f095..2654f095 100644
--- a/examples/forloops.c
+++ b/misc/examples/forloops.c
diff --git a/examples/gauss1.c b/misc/examples/gauss1.c
index 675ff338..675ff338 100644
--- a/examples/gauss1.c
+++ b/misc/examples/gauss1.c
diff --git a/examples/gauss2.c b/misc/examples/gauss2.c
index 2e07c5a5..2e07c5a5 100644
--- a/examples/gauss2.c
+++ b/misc/examples/gauss2.c
diff --git a/examples/hashmap.c b/misc/examples/hashmap.c
index f59ed824..f59ed824 100644
--- a/examples/hashmap.c
+++ b/misc/examples/hashmap.c
diff --git a/examples/inits.c b/misc/examples/inits.c
index 021a3e0a..021a3e0a 100644
--- a/examples/inits.c
+++ b/misc/examples/inits.c
diff --git a/examples/intrusive.c b/misc/examples/intrusive.c
index acf4416d..acf4416d 100644
--- a/examples/intrusive.c
+++ b/misc/examples/intrusive.c
diff --git a/examples/list.c b/misc/examples/list.c
index a538d93c..a538d93c 100644
--- a/examples/list.c
+++ b/misc/examples/list.c
diff --git a/examples/list_erase.c b/misc/examples/list_erase.c
index c1a2aa97..c1a2aa97 100644
--- a/examples/list_erase.c
+++ b/misc/examples/list_erase.c
diff --git a/examples/list_splice.c b/misc/examples/list_splice.c
index f7bac0d6..f7bac0d6 100644
--- a/examples/list_splice.c
+++ b/misc/examples/list_splice.c
diff --git a/examples/lower_bound.c b/misc/examples/lower_bound.c
index 2477bc14..2477bc14 100644
--- a/examples/lower_bound.c
+++ b/misc/examples/lower_bound.c
diff --git a/examples/make.sh b/misc/examples/make.sh
index bd1392fc..bd1392fc 100755
--- a/examples/make.sh
+++ b/misc/examples/make.sh
diff --git a/examples/mapmap.c b/misc/examples/mapmap.c
index 488cc539..488cc539 100644
--- a/examples/mapmap.c
+++ b/misc/examples/mapmap.c
diff --git a/examples/mmap.c b/misc/examples/mmap.c
index 3934cf26..3934cf26 100644
--- a/examples/mmap.c
+++ b/misc/examples/mmap.c
diff --git a/examples/multimap.c b/misc/examples/multimap.c
index e72bdce3..e72bdce3 100644
--- a/examples/multimap.c
+++ b/misc/examples/multimap.c
diff --git a/examples/music_arc.c b/misc/examples/music_arc.c
index 162c4c2f..162c4c2f 100644
--- a/examples/music_arc.c
+++ b/misc/examples/music_arc.c
diff --git a/examples/new_arr.c b/misc/examples/new_arr.c
index 871cfae0..871cfae0 100644
--- a/examples/new_arr.c
+++ b/misc/examples/new_arr.c
diff --git a/examples/new_deq.c b/misc/examples/new_deq.c
index 39149140..39149140 100644
--- a/examples/new_deq.c
+++ b/misc/examples/new_deq.c
diff --git a/examples/new_list.c b/misc/examples/new_list.c
index 6dbe80b4..6dbe80b4 100644
--- a/examples/new_list.c
+++ b/misc/examples/new_list.c
diff --git a/examples/new_map.c b/misc/examples/new_map.c
index f43d4217..f43d4217 100644
--- a/examples/new_map.c
+++ b/misc/examples/new_map.c
diff --git a/examples/new_pque.c b/misc/examples/new_pque.c
index 2bb1d729..2bb1d729 100644
--- a/examples/new_pque.c
+++ b/misc/examples/new_pque.c
diff --git a/examples/new_queue.c b/misc/examples/new_queue.c
index bc7a95c9..bc7a95c9 100644
--- a/examples/new_queue.c
+++ b/misc/examples/new_queue.c
diff --git a/examples/new_smap.c b/misc/examples/new_smap.c
index c77aa185..c77aa185 100644
--- a/examples/new_smap.c
+++ b/misc/examples/new_smap.c
diff --git a/examples/new_sptr.c b/misc/examples/new_sptr.c
index 2c6b28d6..2c6b28d6 100644
--- a/examples/new_sptr.c
+++ b/misc/examples/new_sptr.c
diff --git a/examples/new_vec.c b/misc/examples/new_vec.c
index 84e4c7b2..84e4c7b2 100644
--- a/examples/new_vec.c
+++ b/misc/examples/new_vec.c
diff --git a/examples/person_arc.c b/misc/examples/person_arc.c
index a7bf2a6f..a7bf2a6f 100644
--- a/examples/person_arc.c
+++ b/misc/examples/person_arc.c
diff --git a/examples/phonebook.c b/misc/examples/phonebook.c
index be068409..be068409 100644
--- a/examples/phonebook.c
+++ b/misc/examples/phonebook.c
diff --git a/examples/prime.c b/misc/examples/prime.c
index 287fb69b..287fb69b 100644
--- a/examples/prime.c
+++ b/misc/examples/prime.c
diff --git a/examples/priority.c b/misc/examples/priority.c
index f6e63205..f6e63205 100644
--- a/examples/priority.c
+++ b/misc/examples/priority.c
diff --git a/examples/queue.c b/misc/examples/queue.c
index f39c4b8b..f39c4b8b 100644
--- a/examples/queue.c
+++ b/misc/examples/queue.c
diff --git a/examples/random.c b/misc/examples/random.c
index fe64290d..fe64290d 100644
--- a/examples/random.c
+++ b/misc/examples/random.c
diff --git a/examples/rawptr_elements.c b/misc/examples/rawptr_elements.c
index 4b3d2056..4b3d2056 100644
--- a/examples/rawptr_elements.c
+++ b/misc/examples/rawptr_elements.c
diff --git a/examples/read.c b/misc/examples/read.c
index 4efdcfeb..4efdcfeb 100644
--- a/examples/read.c
+++ b/misc/examples/read.c
diff --git a/examples/regex1.c b/misc/examples/regex1.c
index 7a22220d..7a22220d 100644
--- a/examples/regex1.c
+++ b/misc/examples/regex1.c
diff --git a/examples/regex2.c b/misc/examples/regex2.c
index dbf6aae4..dbf6aae4 100644
--- a/examples/regex2.c
+++ b/misc/examples/regex2.c
diff --git a/examples/regex_match.c b/misc/examples/regex_match.c
index 376b002e..376b002e 100644
--- a/examples/regex_match.c
+++ b/misc/examples/regex_match.c
diff --git a/examples/regex_replace.c b/misc/examples/regex_replace.c
index e296dfd8..e296dfd8 100644
--- a/examples/regex_replace.c
+++ b/misc/examples/regex_replace.c
diff --git a/examples/replace.c b/misc/examples/replace.c
index 15cf3bae..15cf3bae 100644
--- a/examples/replace.c
+++ b/misc/examples/replace.c
diff --git a/examples/shape.c b/misc/examples/shape.c
index a17208ef..a17208ef 100644
--- a/examples/shape.c
+++ b/misc/examples/shape.c
diff --git a/examples/shape.cpp b/misc/examples/shape.cpp
index ea1f53d2..ea1f53d2 100644
--- a/examples/shape.cpp
+++ b/misc/examples/shape.cpp
diff --git a/examples/sidebyside.cpp b/misc/examples/sidebyside.cpp
index 80c934a4..80c934a4 100644
--- a/examples/sidebyside.cpp
+++ b/misc/examples/sidebyside.cpp
diff --git a/examples/sorted_map.c b/misc/examples/sorted_map.c
index c4a05c76..c4a05c76 100644
--- a/examples/sorted_map.c
+++ b/misc/examples/sorted_map.c
diff --git a/examples/splitstr.c b/misc/examples/splitstr.c
index a3c12a3a..a3c12a3a 100644
--- a/examples/splitstr.c
+++ b/misc/examples/splitstr.c
diff --git a/examples/sso_map.c b/misc/examples/sso_map.c
index cc5e16a1..cc5e16a1 100644
--- a/examples/sso_map.c
+++ b/misc/examples/sso_map.c
diff --git a/examples/sso_substr.c b/misc/examples/sso_substr.c
index be372a8d..be372a8d 100644
--- a/examples/sso_substr.c
+++ b/misc/examples/sso_substr.c
diff --git a/examples/stack.c b/misc/examples/stack.c
index a6a4a492..a6a4a492 100644
--- a/examples/stack.c
+++ b/misc/examples/stack.c
diff --git a/examples/sview_split.c b/misc/examples/sview_split.c
index d22fccd1..d22fccd1 100644
--- a/examples/sview_split.c
+++ b/misc/examples/sview_split.c
diff --git a/examples/unordered_set.c b/misc/examples/unordered_set.c
index a0b639da..a0b639da 100644
--- a/examples/unordered_set.c
+++ b/misc/examples/unordered_set.c
diff --git a/examples/utf8replace_c.c b/misc/examples/utf8replace_c.c
index 22a5c990..22a5c990 100644
--- a/examples/utf8replace_c.c
+++ b/misc/examples/utf8replace_c.c
diff --git a/examples/utf8replace_rs.rs b/misc/examples/utf8replace_rs.rs
index 717978aa..717978aa 100644
--- a/examples/utf8replace_rs.rs
+++ b/misc/examples/utf8replace_rs.rs
diff --git a/examples/vikings.c b/misc/examples/vikings.c
index 26a74757..26a74757 100644
--- a/examples/vikings.c
+++ b/misc/examples/vikings.c
diff --git a/examples/words.c b/misc/examples/words.c
index 097447aa..097447aa 100644
--- a/examples/words.c
+++ b/misc/examples/words.c
diff --git a/include/stc/alt/csmap.h b/misc/include/alt/csmap.h
index 65a9f80b..4b4e764c 100644
--- a/include/stc/alt/csmap.h
+++ b/misc/include/alt/csmap.h
@@ -70,7 +70,7 @@ int main(void) {
#define _i_SET_ONLY c_false
#define _i_keyref(vp) (&(vp)->first)
#endif
-#include <stc/template.h>
+#include <stc/priv/template.h>
#if !c_option(c_is_forward)
_cx_deftypes(_c_aatree_types, _cx_self, i_key, i_val, i_size, _i_MAP_ONLY, _i_SET_ONLY);
@@ -509,4 +509,4 @@ _cx_memb(_drop)(_cx_self* self) {
#undef _i_MAP_ONLY
#undef _i_SET_ONLY
#define CSMAP_H_INCLUDED
-#include <stc/template.h>
+#include <stc/priv/template.h>
diff --git a/include/stc/alt/cstr.h b/misc/include/alt/cstr.h
index ecb9c9fb..ecb9c9fb 100644
--- a/include/stc/alt/cstr.h
+++ b/misc/include/alt/cstr.h
diff --git a/misc/include/fmt.h b/misc/include/fmt.h
new file mode 100644
index 00000000..df1fe990
--- /dev/null
+++ b/misc/include/fmt.h
@@ -0,0 +1,253 @@
+#ifndef FMT_INCLUDED
+#define FMT_INCLUDED
+/*
+void fmt_print(dst, fmt, ...);
+void fmt_destroy(fmt_buffer* buf);
+
+ dst - destination
+ int 1=stdout, 2=stderr
+ FILE* file Write to a file
+ char* strbuf Write to a pre-allocated string buffer
+ fmt_buffer* b Auto realloc the needed memory. Set b->stream=1 for stream-mode.
+ b->data must be freed after usage.
+
+ fmt - format string
+ {} Auto-detected format. If :MOD is not specified,
+ float will use ".8g" format, and double ".16g".
+ {:MOD} Format modifiers: < left align (replaces -), default for char*, char.
+ > right align, default for numbers.
+ Other than that MOD can be normal printf format modifiers.
+ {{, }} Print chars {, and }. (note: a single % prints %).
+
+* C11 or higher required.
+* MAX 255 chars fmt string by default. MAX 12 arguments after fmt string.
+* Static linking by default, shared symbols by defining FMT_HEADER / FMT_IMPLEMENT.
+* (c) operamint, 2022, MIT License.
+-----------------------------------------------------------------------------------
+#include "fmt.h"
+
+int main() {
+ const double pi = 3.141592653589793;
+ const size_t x = 1234567890;
+ const char* string = "Hello world";
+ const char z = 'z';
+ _Bool flag = 1;
+ unsigned char r = 123, g = 214, b = 90, w = 110;
+ char buffer[64];
+
+ fmt_print(1, "Color: ({} {} {}), {}\n", r, g, b, flag);
+ fmt_print(1, "{:10} {:10} {:10.2f}\n", 42ull, 43, pi);
+ fmt_print(stdout, "{:>10} {:>10} {:>10}\n", z, z, w);
+ fmt_print(stdout, "{:10} {:10} {:10}\n", "Hello", "Mad", "World");
+ fmt_print(stderr, "100%: {:<20} {:.*} {}\n", string, 4, pi, x);
+ fmt_print(buffer, "Precision: {} {:.10} {}", string, pi, x);
+ fmt_print(1, "{}\n", buffer);
+ fmt_print(1, "Vector: ({}, {}, {})\n", 3.2, 3.3, pi);
+
+ fmt_buffer out[1] = {{.stream=1}};
+ fmt_print(out, "{} {}", "Pi is:", pi);
+ fmt_print(1, "{}, len={}, cap={}\n", out->data, out->len, out->cap);
+ fmt_print(out, "{} {}", ", Pi squared is:", pi*pi);
+ fmt_print(1, "{}, len={}, cap={}\n", out->data, out->len, out->cap);
+ fmt_destroy(out);
+}
+*/
+#include <stdio.h>
+#include <assert.h>
+
+#define fmt_OVERLOAD(name, ...) \
+ fmt_JOIN(name, fmt_NUMARGS(__VA_ARGS__))(__VA_ARGS__)
+#define fmt_CONCAT(a, b) a ## b
+#define fmt_JOIN(a, b) fmt_CONCAT(a, b)
+#define fmt_EXPAND(...) __VA_ARGS__
+#define fmt_NUMARGS(...) _fmt_APPLY_ARG_N((__VA_ARGS__, _fmt_RSEQ_N))
+
+#define _fmt_APPLY_ARG_N(args) fmt_EXPAND(_fmt_ARG_N args)
+#define _fmt_RSEQ_N 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
+#define _fmt_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
+ _14, _15, _16, N, ...) N
+
+#if defined FMT_HEADER || defined FMT_IMPLEMENT
+# define FMT_API
+#else
+# define FMT_API static inline
+#endif
+
+typedef struct {
+ char* data;
+ size_t cap, len;
+ _Bool stream;
+} fmt_buffer;
+
+FMT_API void fmt_destroy(fmt_buffer* buf);
+FMT_API int _fmt_parse(char* p, int nargs, const char *fmt, ...);
+FMT_API void _fmt_iprint(int fd, const char* fmt, ...);
+FMT_API void _fmt_bprint(fmt_buffer*, const char* fmt, ...);
+
+#ifndef FMT_MAX
+#define FMT_MAX 256
+#endif
+
+/* Primary function. */
+#define fmt_print(...) fmt_OVERLOAD(fmt_print, __VA_ARGS__)
+#define fmt_print2(to, fmt) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 0, fmt); \
+ assert(_n == 0); _fmt_fn(to)(to, fmt); } while (0)
+#define fmt_print3(to, fmt, c) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 1, fmt, _fc(c)); \
+ assert(_n == 1); _fmt_fn(to)(to, _fs, c); } while (0)
+#define fmt_print4(to, fmt, c, d) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 2, fmt, _fc(c), _fc(d)); \
+ assert(_n == 2); _fmt_fn(to)(to, _fs, c, d); } while (0)
+#define fmt_print5(to, fmt, c, d, e) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 3, fmt, _fc(c), _fc(d), _fc(e)); \
+ assert(_n == 3); _fmt_fn(to)(to, _fs, c, d, e); } while (0)
+#define fmt_print6(to, fmt, c, d, e, f) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 4, fmt, _fc(c), _fc(d), _fc(e), _fc(f)); \
+ assert(_n == 4); _fmt_fn(to)(to, _fs, c, d, e, f); } while (0)
+#define fmt_print7(to, fmt, c, d, e, f, g) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 5, fmt, _fc(c), _fc(d), _fc(e), _fc(f), _fc(g)); \
+ assert(_n == 5); _fmt_fn(to)(to, _fs, c, d, e, f, g); } while (0)
+#define fmt_print8(to, fmt, c, d, e, f, g, h) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 6, fmt, _fc(c), _fc(d), _fc(e), _fc(f), _fc(g), _fc(h)); \
+ assert(_n == 6); _fmt_fn(to)(to, _fs, c, d, e, f, g, h); } while (0)
+#define fmt_print9(to, fmt, c, d, e, f, g, h, i) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 7, fmt, _fc(c), _fc(d), _fc(e), _fc(f), _fc(g), _fc(h), _fc(i)); \
+ assert(_n == 7); _fmt_fn(to)(to, _fs, c, d, e, f, g, h, i); } while (0)
+#define fmt_print10(to, fmt, c, d, e, f, g, h, i, j) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 8, fmt, _fc(c), _fc(d), _fc(e), _fc(f), _fc(g), _fc(h), \
+ _fc(i), _fc(j)); \
+ assert(_n == 8); _fmt_fn(to)(to, _fs, c, d, e, f, g, h, i, j); } while (0)
+#define fmt_print11(to, fmt, c, d, e, f, g, h, i, j, k) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 9, fmt, _fc(c), _fc(d), _fc(e), _fc(f), _fc(g), _fc(h), \
+ _fc(i), _fc(j), _fc(k)); \
+ assert(_n == 9); _fmt_fn(to)(to, _fs, c, d, e, f, g, h, i, j, k); } while (0)
+#define fmt_print12(to, fmt, c, d, e, f, g, h, i, j, k, m) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 10, fmt, _fc(c), _fc(d), _fc(e), _fc(f), _fc(g), _fc(h), \
+ _fc(i), _fc(j), _fc(k), _fc(m)); \
+ assert(_n == 10); _fmt_fn(to)(to, _fs, c, d, e, f, g, h, i, j, k, m); } while (0)
+#define fmt_print13(to, fmt, c, d, e, f, g, h, i, j, k, m, n) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 11, fmt, _fc(c), _fc(d), _fc(e), _fc(f), _fc(g), _fc(h), \
+ _fc(i), _fc(j), _fc(k), _fc(m), _fc(n)); \
+ assert(_n == 11); _fmt_fn(to)(to, _fs, c, d, e, f, g, h, i, j, k, m, n); } while (0)
+#define fmt_print14(to, fmt, c, d, e, f, g, h, i, j, k, m, n, o) \
+ do { char _fs[FMT_MAX]; int _n = _fmt_parse(_fs, 12, fmt, _fc(c), _fc(d), _fc(e), _fc(f), _fc(g), _fc(h), \
+ _fc(i), _fc(j), _fc(k), _fc(m), _fc(n), _fc(o)); \
+ assert(_n == 12); _fmt_fn(to)(to, _fs, c, d, e, f, g, h, i, j, k, m, n, o); } while (0)
+
+#define _fmt_fn(x) _Generic ((x), \
+ FILE*: fprintf, \
+ char*: sprintf, \
+ int: _fmt_iprint, \
+ fmt_buffer*: _fmt_bprint)
+
+#if defined(_MSC_VER) && !defined(__clang__)
+# define _signed_char_hhd
+#else
+# define _signed_char_hhd signed char: "hhd",
+#endif
+
+#define _fc(x) _Generic (x, \
+ _Bool: "d", \
+ unsigned char: "hhu", \
+ _signed_char_hhd \
+ char: "c", \
+ short: "hd", \
+ unsigned short: "hu", \
+ int: "d", \
+ unsigned: "u", \
+ long: "ld", \
+ unsigned long: "lu", \
+ long long: "lld", \
+ unsigned long long: "llu", \
+ float: "g", \
+ double: "@g", \
+ long double: "@Lg", \
+ char*: "s", \
+ void*: "p", \
+ const char*: "s", \
+ const void*: "p")
+
+#if defined FMT_IMPLEMENT || !(defined FMT_HEADER || defined FMT_IMPLEMENT)
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
+FMT_API void fmt_destroy(fmt_buffer* buf) {
+ free(buf->data);
+}
+
+FMT_API void _fmt_iprint(int fd, const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ vfprintf(fd == 1 ? stdout : stderr, fmt, args);
+ va_end(args);
+}
+
+FMT_API void _fmt_bprint(fmt_buffer* buf, const char* fmt, ...) {
+ va_list args, args2;
+ va_start(args, fmt);
+ va_copy(args2, args);
+ const int n = vsnprintf(NULL, 0U, fmt, args);
+ const size_t pos = buf->stream ? buf->len : 0U;
+ buf->len = pos + (size_t)n;
+ if (buf->len > buf->cap) {
+ buf->cap = buf->len + buf->cap/2;
+ buf->data = (char*)realloc(buf->data, buf->cap + 1);
+ }
+ vsprintf(buf->data + pos, fmt, args2);
+ va_end(args2);
+ va_end(args);
+}
+
+FMT_API int _fmt_parse(char* p, int nargs, const char *fmt, ...) {
+ char *arg, *p0, ch;
+ int n = 0, empty;
+ va_list args;
+ va_start(args, fmt);
+ do {
+ switch ((ch = *fmt)) {
+ case '%':
+ *p++ = '%';
+ break;
+ case '}':
+ if (*++fmt == '}') break; /* ok */
+ n = 99;
+ continue;
+ case '{':
+ if (*++fmt == '{') break; /* ok */
+ if (++n > nargs) continue;
+ if (*fmt != ':' && *fmt != '}') n = 99;
+ fmt += (*fmt == ':');
+ empty = *fmt == '}';
+ arg = va_arg(args, char *);
+ *p++ = '%', p0 = p;
+ while (1) switch (*fmt) {
+ case '\0': n = 99; /* nobreak */
+ case '}': goto done;
+ case '<': *p++ = '-', ++fmt; break;
+ case '>': p0 = NULL; /* nobreak */
+ case '-': ++fmt; break;
+ case '*': if (++n <= nargs) arg = va_arg(args, char *); /* nobreak */
+ default: *p++ = *fmt++;
+ }
+ done:
+ switch (*arg) {
+ case 'g': if (empty) memcpy(p, ".8", 2), p += 2; break;
+ case '@': ++arg; if (empty) memcpy(p, ".16", 3), p += 3; break;
+ }
+ if (!strchr("csdioxXufFeEaAgGnp", fmt[-1]))
+ while (*arg) *p++ = *arg++;
+ if (p0 && (p[-1] == 's' || p[-1] == 'c')) /* left-align str */
+ memmove(p0 + 1, p0, p++ - p0), *p0 = '-';
+ fmt += *fmt == '}';
+ continue;
+ }
+ *p++ = *fmt++;
+ } while (ch);
+ va_end(args);
+ return n;
+}
+#endif
+#endif \ No newline at end of file
diff --git a/include/stc/stctest.h b/misc/include/stctest.h
index 9718af7f..9718af7f 100644
--- a/include/stc/stctest.h
+++ b/misc/include/stctest.h
diff --git a/tests/cregex_test.c b/misc/tests/cregex_test.c
index b9642159..b9642159 100644
--- a/tests/cregex_test.c
+++ b/misc/tests/cregex_test.c