summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--docs/carc_api.md2
-rw-r--r--docs/cbox_api.md2
-rw-r--r--docs/cdeq_api.md2
-rw-r--r--docs/clist_api.md2
-rw-r--r--docs/cvec_api.md4
-rw-r--r--include/stc/carc.h64
-rw-r--r--include/stc/cbox.h65
-rw-r--r--include/stc/ccommon.h2
-rw-r--r--include/stc/priv/template.h29
-rw-r--r--include/stc/priv/template2.h2
-rw-r--r--misc/examples/linkedlists/intrusive.c2
-rw-r--r--misc/examples/linkedlists/list.c2
-rw-r--r--misc/examples/linkedlists/new_list.c2
-rw-r--r--misc/examples/mixed/astar.c1
-rw-r--r--misc/examples/mixed/complex.c1
-rw-r--r--misc/examples/mixed/demos.c3
-rw-r--r--misc/examples/smartpointers/arc_containers.c4
-rw-r--r--misc/examples/smartpointers/arc_demo.c3
-rw-r--r--misc/examples/smartpointers/arcvec_erase.c3
-rw-r--r--misc/examples/smartpointers/box.c1
-rw-r--r--misc/examples/smartpointers/box2.c1
-rw-r--r--misc/examples/smartpointers/music_arc.c4
-rw-r--r--misc/examples/smartpointers/new_sptr.c3
-rw-r--r--misc/examples/smartpointers/person_arc.c3
-rw-r--r--misc/examples/sortedmaps/csmap_insert.c1
-rw-r--r--misc/examples/sortedmaps/multimap.c1
-rw-r--r--misc/examples/vectors/lower_bound.c2
28 files changed, 99 insertions, 116 deletions
diff --git a/README.md b/README.md
index 69c51417..48ccdd6f 100644
--- a/README.md
+++ b/README.md
@@ -251,7 +251,7 @@ struct Point { float x, y; };
#include <stc/cvec.h> // cvec_pnt: vector of struct Point
#define i_key int
-#define i_cmp_native // enable sort/search. Use native `<` and `==` operators
+#define i_use_cmp // enable sort/search. Use native `<` and `==` operators
#include <stc/clist.h> // clist_int: singly linked list
#define i_key int
@@ -658,7 +658,7 @@ STC is generally very memory efficient. Memory usage for the different container
- Removed deprecated <stc/crandom.h>. Use `<stc/crand.h>` with the new API.
- Reverted names _unif and _norm back to `_uniform` and `_normal`.
- Removed default comparison for **clist**, **cvec** and **cdeq**:
- - Define `i_cmp_native` to enable comparison for built-in i_key types (<, ==).
+ - Define `i_use_cmp` to enable comparison for built-in i_key types (<, ==).
- Use of `i_keyclass` still expects comparison functions to be defined.
- Use of `i_keyboxed` compares stored pointers instead of pointed to values if comparison not defined.
- Renamed input enum flags for ***cregex***-functions.
diff --git a/docs/carc_api.md b/docs/carc_api.md
index fb79019a..3e394378 100644
--- a/docs/carc_api.md
+++ b/docs/carc_api.md
@@ -25,7 +25,7 @@ See similar c++ class [std::shared_ptr](https://en.cppreference.com/w/cpp/memory
#define i_cmp <f> // three-way compareison. REQUIRED IF i_key is a non-integral type
// Note that containers of carcs will "inherit" i_cmp
// when using carc in containers with i_valboxed MyArc - ie. the i_type.
-#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_use_cmp // define instead of i_cmp only when i_key is an integral/native-type.
#define i_keydrop <f> // destroy element func - defaults to empty destruct
#define i_keyclone <f> // REQUIRED if i_keydrop is defined, unless 'i_opt c_no_clone' is defined.
diff --git a/docs/cbox_api.md b/docs/cbox_api.md
index 0e6fca64..c683d9ef 100644
--- a/docs/cbox_api.md
+++ b/docs/cbox_api.md
@@ -19,7 +19,7 @@ See similar c++ class [std::unique_ptr](https://en.cppreference.com/w/cpp/memory
#define i_cmp <f> // three-way compareison. REQUIRED IF i_key is a non-integral type
// Note that containers of carcs will "inherit" i_cmp
// when using carc in containers with i_valboxed MyArc - ie. the i_type.
-#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_use_cmp // define instead of i_cmp only when i_key is an integral/native-type.
#define i_keydrop <f> // destroy element func - defaults to empty destruct
#define i_keyclone <f> // REQUIRED if i_keydrop is defined, unless 'i_opt c_no_clone' is defined.
diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md
index c544f213..3ce58e78 100644
--- a/docs/cdeq_api.md
+++ b/docs/cdeq_api.md
@@ -13,7 +13,7 @@ See the c++ class [std::deque](https://en.cppreference.com/w/cpp/container/deque
#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
#define i_type <t> // cdeq container type name
#define i_cmp <f> // three-way compare of two i_keyraw*.
-#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_use_cmp // define instead of i_cmp only when i_key is an integral/native-type.
#define i_keydrop <f> // destroy value func - defaults to empty destruct
#define i_keyclone <f> // REQUIRED IF i_keydrop is defined
diff --git a/docs/clist_api.md b/docs/clist_api.md
index d8d614c2..a24d813b 100644
--- a/docs/clist_api.md
+++ b/docs/clist_api.md
@@ -25,7 +25,7 @@ See the c++ class [std::list](https://en.cppreference.com/w/cpp/container/list)
#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
#define i_type <t> // clist container type name
#define i_cmp <f> // three-way compare two i_keyraw*
-#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_use_cmp // define instead of i_cmp only when i_key is an integral/native-type.
#define i_keydrop <f> // destroy value func - defaults to empty destruct
#define i_keyclone <f> // REQUIRED IF i_keydrop defined
diff --git a/docs/cvec_api.md b/docs/cvec_api.md
index 3f827df6..8997ed51 100644
--- a/docs/cvec_api.md
+++ b/docs/cvec_api.md
@@ -15,7 +15,7 @@ See the c++ class [std::vector](https://en.cppreference.com/w/cpp/container/vect
#define i_type <t> // container type name
#define i_key <t> // element type: REQUIRED. Note: i_val* may be specified instead of i_key*.
#define i_cmp <f> // three-way compare two i_keyraw*
-#define i_cmp_native // define instead of i_cmp only when i_key is an integral/native-type.
+#define i_use_cmp // define instead of i_cmp only when i_key is an integral/native-type.
#define i_keydrop <f> // destroy value func - defaults to empty destruct
#define i_keyclone <f> // REQUIRED IF i_keydrop defined
@@ -224,4 +224,4 @@ int main(void) {
c_drop(UVec, &vec, &vec2); // cleanup
}
-``` \ No newline at end of file
+```
diff --git a/include/stc/carc.h b/include/stc/carc.h
index 9ba2ddd1..e1dfe14e 100644
--- a/include/stc/carc.h
+++ b/include/stc/carc.h
@@ -176,50 +176,40 @@ STC_INLINE void _cx_MEMB(_assign)(_cx_Self* self, _cx_Self ptr) {
*self = ptr;
}
-#if defined _i_has_cmp
+#if defined i_use_cmp
STC_INLINE int _cx_MEMB(_raw_cmp)(const _cx_raw* rx, const _cx_raw* ry)
{ return i_cmp(rx, ry); }
- STC_INLINE int _cx_MEMB(_cmp)(const _cx_Self* self, const _cx_Self* other) {
- _cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
- return i_cmp((&rx), (&ry));
- }
-#else
- STC_INLINE int _cx_MEMB(_raw_cmp)(const _cx_raw* rx, const _cx_raw* ry)
- { return c_default_cmp(&rx, &ry); }
-
- STC_INLINE int _cx_MEMB(_cmp)(const _cx_Self* self, const _cx_Self* other) {
- return c_default_cmp(&self->get, &other->get);
- }
-#endif
-#if defined _i_has_eq || defined _i_has_cmp
STC_INLINE bool _cx_MEMB(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry)
{ return i_eq(rx, ry); }
-
- STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other) {
- _cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
- return i_eq((&rx), (&ry));
- }
-#else
- STC_INLINE bool _cx_MEMB(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry)
- { return rx == ry; }
-
- STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other) {
- return self->get == other->get;
- }
-#endif
-#if defined i_hash
+ #ifndef i_no_hash
STC_INLINE uint64_t _cx_MEMB(_raw_hash)(const _cx_raw* rx)
{ return i_hash(rx); }
-
- STC_INLINE uint64_t _cx_MEMB(_hash)(const _cx_Self* self)
- { _cx_raw rx = i_keyto(self->get); return i_hash(&rx); }
-#else
- STC_INLINE uint64_t _cx_MEMB(_raw_hash)(const _cx_raw* rx)
- { return c_default_hash(&rx); }
-
- STC_INLINE uint64_t _cx_MEMB(_hash)(const _cx_Self* self)
- { return c_default_hash(&self->get); }
+ #endif // i_no_hash
+
+ #if defined i_ptr_cmp
+ STC_INLINE int _cx_MEMB(_cmp)(const _cx_Self* self, const _cx_Self* other) {
+ return c_default_cmp(&self->get, &other->get);
+ }
+ STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other) {
+ return self->get == other->get;
+ }
+ STC_INLINE uint64_t _cx_MEMB(_hash)(const _cx_Self* self)
+ { return c_default_hash(&self->get); }
+ #else
+ STC_INLINE int _cx_MEMB(_cmp)(const _cx_Self* self, const _cx_Self* other) {
+ _cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
+ return i_cmp((&rx), (&ry));
+ }
+ STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other) {
+ _cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
+ return i_eq((&rx), (&ry));
+ }
+ #ifndef i_no_hash
+ STC_INLINE uint64_t _cx_MEMB(_hash)(const _cx_Self* self)
+ { _cx_raw rx = i_keyto(self->get); return i_hash(&rx); }
+ #endif // i_no_hash
+ #endif // i_ptr_cmp
#endif
#undef _i_atomic_inc
diff --git a/include/stc/cbox.h b/include/stc/cbox.h
index 25d41b92..b799c24c 100644
--- a/include/stc/cbox.h
+++ b/include/stc/cbox.h
@@ -159,50 +159,41 @@ STC_INLINE void _cx_MEMB(_assign)(_cx_Self* self, _cx_Self* moved) {
moved->get = NULL;
}
-#if defined _i_has_cmp
+#if defined i_use_cmp
STC_INLINE int _cx_MEMB(_raw_cmp)(const _cx_raw* rx, const _cx_raw* ry)
{ return i_cmp(rx, ry); }
- STC_INLINE int _cx_MEMB(_cmp)(const _cx_Self* self, const _cx_Self* other) {
- _cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
- return i_cmp((&rx), (&ry));
- }
-#else
- STC_INLINE int _cx_MEMB(_raw_cmp)(const _cx_raw* rx, const _cx_raw* ry)
- { return c_default_cmp(&rx, &ry); }
-
- STC_INLINE int _cx_MEMB(_cmp)(const _cx_Self* self, const _cx_Self* other) {
- return c_default_cmp(&self->get, &other->get);
- }
-#endif
-#if defined _i_has_eq || defined _i_has_cmp
STC_INLINE bool _cx_MEMB(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry)
{ return i_eq(rx, ry); }
-
- STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other) {
- _cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
- return i_eq((&rx), (&ry));
- }
-#else
- STC_INLINE bool _cx_MEMB(_raw_eq)(const _cx_raw* rx, const _cx_raw* ry)
- { return rx == ry; }
-
- STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other) {
- return self->get == other->get;
- }
-#endif
-#if defined i_hash
+ #ifndef i_no_hash
STC_INLINE uint64_t _cx_MEMB(_raw_hash)(const _cx_raw* rx)
{ return i_hash(rx); }
-
- STC_INLINE uint64_t _cx_MEMB(_hash)(const _cx_Self* self)
- { _cx_raw rx = i_keyto(self->get); return i_hash(&rx); }
-#else
- STC_INLINE uint64_t _cx_MEMB(_raw_hash)(const _cx_raw* rx)
- { return c_default_hash(&rx); }
-
- STC_INLINE uint64_t _cx_MEMB(_hash)(const _cx_Self* self)
- { return c_default_hash(&self->get); }
+ #endif // i_no_hash
+
+ #if defined i_ptr_cmp
+ STC_INLINE int _cx_MEMB(_cmp)(const _cx_Self* self, const _cx_Self* other) {
+ return c_default_cmp(&self->get, &other->get);
+ }
+ STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other) {
+ return self->get == other->get;
+ }
+ STC_INLINE uint64_t _cx_MEMB(_hash)(const _cx_Self* self)
+ { return c_default_hash(&self->get); }
+ #else
+ STC_INLINE int _cx_MEMB(_cmp)(const _cx_Self* self, const _cx_Self* other) {
+ _cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
+ return i_cmp((&rx), (&ry));
+ }
+ STC_INLINE bool _cx_MEMB(_eq)(const _cx_Self* self, const _cx_Self* other) {
+ _cx_raw rx = i_keyto(self->get), ry = i_keyto(other->get);
+ return i_eq((&rx), (&ry));
+ }
+ #ifndef i_no_hash
+ STC_INLINE uint64_t _cx_MEMB(_hash)(const _cx_Self* self)
+ { _cx_raw rx = i_keyto(self->get); return i_hash(&rx); }
+ #endif // i_no_hash
+ #endif // i_ptr_cmp
#endif
+
#include "priv/template2.h"
#undef _i_cbox
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 2528b94f..b37ad1da 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -117,7 +117,7 @@ typedef long long _llong;
#define c_no_clone (1<<2)
#define c_no_emplace (1<<3)
#define c_no_cmp (1<<4)
-#define c_native_cmp (1<<5)
+#define c_use_cmp (1<<5)
#define c_no_hash (1<<6)
/* Function macros and others */
diff --git a/include/stc/priv/template.h b/include/stc/priv/template.h
index 49b4d8da..fae9093e 100644
--- a/include/stc/priv/template.h
+++ b/include/stc/priv/template.h
@@ -102,8 +102,8 @@
#if c_option(c_no_emplace)
#define i_no_emplace
#endif
-#if c_option(c_native_cmp)
- #define i_cmp_native
+#if c_option(c_use_cmp) || defined _i_ismap || defined _i_isset || defined _i_ispque
+ #define i_use_cmp
#endif
#if c_option(c_no_clone) || defined _i_carc
#define i_no_clone
@@ -127,7 +127,7 @@
#elif defined i_keyboxed
#define i_keyclass i_keyboxed
#define i_rawclass c_PASTE(i_keyboxed, _raw)
- #ifndef i_no_cmp
+ #if !defined i_no_cmp && defined i_use_cmp
#define i_eq c_PASTE(i_keyboxed, _raw_eq)
#endif
#endif
@@ -138,7 +138,7 @@
#define i_rawclass i_key
#endif
-#ifdef i_keyclass
+#if defined i_keyclass
#define i_key i_keyclass
#ifndef i_keyclone
#define i_keyclone c_PASTE(i_key, _clone)
@@ -154,8 +154,8 @@
#endif
#endif
-#ifdef i_rawclass
- #if !(defined i_cmp || defined i_no_cmp)
+#if defined i_rawclass && defined i_use_cmp
+ #if !(defined i_cmp || defined i_less || defined i_no_cmp)
#define i_cmp c_PASTE(i_keyraw, _cmp)
#endif
#if !(defined i_hash || defined i_no_hash || defined i_no_cmp)
@@ -171,26 +171,29 @@
#endif
#endif
-#ifndef i_no_cmp
- #if defined i_cmp || defined i_less || defined i_cmp_native
+#if !defined i_no_cmp
+ #if defined i_cmp || defined i_less || defined i_use_cmp
#define _i_has_cmp
#endif
- #if defined i_eq || defined i_cmp_native
+ #if defined i_eq || defined i_use_cmp
#define _i_has_eq
#endif
#endif
+#if !(defined i_hash || defined i_no_hash || defined i_no_cmp)
+ #define i_hash c_default_hash
+#endif
#if !defined i_key
#error "No i_key or i_val defined"
#elif defined i_keyraw ^ defined i_keyto
#error "Both i_keyraw/i_valraw and i_keyto/i_valto must be defined, if any"
#elif !defined i_no_clone && (defined i_keyclone ^ defined i_keydrop)
- #error "Both i_keyclone/i_valclone and i_keydrop/i_valdrop must be defined, if any"
+ #error "Both i_keyclone/i_valclone and i_keydrop/i_valdrop must be defined, if any (unless i_no_clone defined)."
#elif defined i_from || defined i_drop
#error "i_from / i_drop not supported. Define i_keyfrom/i_valfrom and/or i_keydrop/i_valdrop instead"
#elif defined i_keyraw && defined _i_ishash && !(defined i_hash && (defined _i_has_cmp || defined i_eq))
#error "For cmap/cset, both i_hash and i_eq (or i_less or i_cmp) must be defined when i_keyraw is defined."
-#elif defined i_keyraw && (defined _i_ismap || defined _i_isset || defined _i_ispque) && !defined _i_has_cmp
+#elif defined i_keyraw && defined i_use_cmp && !defined _i_has_cmp
#error "For csmap/csset/cpque, i_cmp or i_less must be defined when i_keyraw is defined."
#endif
@@ -234,10 +237,6 @@
#endif
#endif
-#if !defined i_hash && (!(defined _i_cbox || defined _i_carc) || defined i_cmp_native)
- #define i_hash c_default_hash
-#endif
-
#if defined _i_ismap // ---- process cmap/csmap value i_val, ... ----
#ifdef i_val_str
diff --git a/include/stc/priv/template2.h b/include/stc/priv/template2.h
index 351defde..1e0d4a2e 100644
--- a/include/stc/priv/template2.h
+++ b/include/stc/priv/template2.h
@@ -67,7 +67,7 @@
#undef i_realloc
#undef i_free
-#undef i_cmp_native
+#undef i_use_cmp
#undef i_no_cmp
#undef i_no_hash
#undef i_no_clone
diff --git a/misc/examples/linkedlists/intrusive.c b/misc/examples/linkedlists/intrusive.c
index c7402d09..edb072c7 100644
--- a/misc/examples/linkedlists/intrusive.c
+++ b/misc/examples/linkedlists/intrusive.c
@@ -4,7 +4,7 @@
#define i_type List
#define i_key int
-#define i_cmp_native
+#define i_use_cmp
#include <stc/clist.h>
void printList(List list) {
diff --git a/misc/examples/linkedlists/list.c b/misc/examples/linkedlists/list.c
index 518cc09b..e83dc6b2 100644
--- a/misc/examples/linkedlists/list.c
+++ b/misc/examples/linkedlists/list.c
@@ -5,7 +5,7 @@
#define i_type DList
#define i_key double
-#define i_cmp_native
+#define i_use_cmp
#include <stc/clist.h>
int main(void) {
diff --git a/misc/examples/linkedlists/new_list.c b/misc/examples/linkedlists/new_list.c
index 2112bf1f..7518929a 100644
--- a/misc/examples/linkedlists/new_list.c
+++ b/misc/examples/linkedlists/new_list.c
@@ -27,7 +27,7 @@ int point_cmp(const Point* a, const Point* b) {
#include <stc/clist.h>
#define i_key float
-#define i_cmp_native // use < and == operators for comparison
+#define i_use_cmp // use < and == operators for comparison
#include <stc/clist.h>
void MyStruct_drop(MyStruct* s);
diff --git a/misc/examples/mixed/astar.c b/misc/examples/mixed/astar.c
index 590b7952..d15a9ed7 100644
--- a/misc/examples/mixed/astar.c
+++ b/misc/examples/mixed/astar.c
@@ -61,7 +61,6 @@ point_key_cmp(const point* a, const point* b)
#include <stc/cpque.h>
#define i_key point
-#define i_opt c_no_cmp
#include <stc/cdeq.h>
#define i_key point
diff --git a/misc/examples/mixed/complex.c b/misc/examples/mixed/complex.c
index 4eb1574b..9fcbc417 100644
--- a/misc/examples/mixed/complex.c
+++ b/misc/examples/mixed/complex.c
@@ -14,7 +14,6 @@
#define i_type StackList
#define i_keyclass FloatStack // "class" picks up _clone, _drop, _cmp
-#define i_opt c_no_cmp // exclude FloatStack_cmp(): not defined
#include <stc/clist.h>
#define i_type ListMap
diff --git a/misc/examples/mixed/demos.c b/misc/examples/mixed/demos.c
index 7f5091fd..43c9a7ae 100644
--- a/misc/examples/mixed/demos.c
+++ b/misc/examples/mixed/demos.c
@@ -53,6 +53,7 @@ void vectordemo1(void)
}
#define i_key_str
+#define i_use_cmp
#include <stc/cvec.h>
void vectordemo2(void)
@@ -74,7 +75,7 @@ void vectordemo2(void)
#define i_key int
#define i_tag ix
-#define i_cmp_native
+#define i_use_cmp
#include <stc/clist.h>
void listdemo1(void)
diff --git a/misc/examples/smartpointers/arc_containers.c b/misc/examples/smartpointers/arc_containers.c
index 6209005d..c2bff56f 100644
--- a/misc/examples/smartpointers/arc_containers.c
+++ b/misc/examples/smartpointers/arc_containers.c
@@ -12,11 +12,11 @@
#define i_key Map
#define i_keydrop(p) (printf("drop Arc:\n"), Map_drop(p))
// no need for atomic ref. count in single thread:
-#define i_opt c_no_atomic
+#define i_opt c_no_atomic|c_no_cmp
#include <stc/carc.h>
#define i_type Stack
-#define i_keyboxed Arc // define i_keyboxed for carc/cbox value (not i_key)
+#define i_keyboxed Arc // use i_keyboxed for carc/cbox key
#include <stc/cvec.h>
#define i_type List
diff --git a/misc/examples/smartpointers/arc_demo.c b/misc/examples/smartpointers/arc_demo.c
index 929a48a1..a66d84b0 100644
--- a/misc/examples/smartpointers/arc_demo.c
+++ b/misc/examples/smartpointers/arc_demo.c
@@ -11,13 +11,14 @@ void int_drop(int* x) {
#define i_type Arc // set type name to be defined (instead of 'carc_int')
#define i_key int
#define i_keydrop int_drop // optional, just to display the elements destroyed
-#define i_cmp_native // use int comparison (x < y, x == y).
+#define i_use_cmp // use int comparison (x < y, x == y).
#include <stc/carc.h> // Arc
#define i_keyboxed Arc // note: use i_keyboxed instead of i_key for carc/cbox elements
#include <stc/csset.h> // csset_Arc (like: std::set<std::shared_ptr<int>>)
#define i_keyboxed Arc // note: as above.
+#define i_use_cmp
#include <stc/cvec.h> // cvec_Arc (like: std::vector<std::shared_ptr<int>>)
int main(void)
diff --git a/misc/examples/smartpointers/arcvec_erase.c b/misc/examples/smartpointers/arcvec_erase.c
index 9d757533..0526b6a0 100644
--- a/misc/examples/smartpointers/arcvec_erase.c
+++ b/misc/examples/smartpointers/arcvec_erase.c
@@ -5,11 +5,12 @@ void show_drop(int* x) { printf("drop: %d\n", *x); }
#define i_type Arc
#define i_key int
#define i_keydrop show_drop
-#define i_cmp_native // enable sort/search for int type
+#define i_use_cmp // enable sort/search for int type
#include <stc/carc.h> // Shared pointer to int
#define i_type Vec
#define i_keyboxed Arc
+#define i_use_cmp
#include <stc/cvec.h> // Vec: cvec<Arc>
diff --git a/misc/examples/smartpointers/box.c b/misc/examples/smartpointers/box.c
index 94d126c0..5c8018d4 100644
--- a/misc/examples/smartpointers/box.c
+++ b/misc/examples/smartpointers/box.c
@@ -30,6 +30,7 @@ void Person_drop(Person* p) {
#define i_type PBox
#define i_keyclass Person // "class" binds _cmp, _clone, _drop functions.
+#define i_use_cmp
#include <stc/cbox.h>
#define i_type Persons
diff --git a/misc/examples/smartpointers/box2.c b/misc/examples/smartpointers/box2.c
index eaab1c47..9b782c74 100644
--- a/misc/examples/smartpointers/box2.c
+++ b/misc/examples/smartpointers/box2.c
@@ -22,7 +22,6 @@ typedef struct {
// Box in box:
#define i_type BoxBoxPoint
#define i_keyboxed cbox_Point // NB: use i_keyboxed when value is a cbox or carc!
-#define i_no_cmp
#include <stc/cbox.h> // BoxBoxPoint
Point origin(void) {
diff --git a/misc/examples/smartpointers/music_arc.c b/misc/examples/smartpointers/music_arc.c
index 13d368c3..e9ebbbfe 100644
--- a/misc/examples/smartpointers/music_arc.c
+++ b/misc/examples/smartpointers/music_arc.c
@@ -23,7 +23,7 @@ void Song_drop(Song* s) {
// Define the shared pointer:
#define i_type SongArc
#define i_keyclass Song
-#define i_no_hash // no hash fn for Song, fallback hash pointer to Song.
+#define i_opt c_use_cmp|c_no_hash
#include <stc/carc.h>
// ... and a vector of them
@@ -64,4 +64,4 @@ void example3(void)
int main(void)
{
example3();
-}
+} \ No newline at end of file
diff --git a/misc/examples/smartpointers/new_sptr.c b/misc/examples/smartpointers/new_sptr.c
index 3c6fa16c..50e28ae2 100644
--- a/misc/examples/smartpointers/new_sptr.c
+++ b/misc/examples/smartpointers/new_sptr.c
@@ -10,12 +10,13 @@ uint64_t Person_hash(const Person* p);
#define i_type PersonArc
#define i_keyclass Person // "class" assume _clone, _drop, _cmp, _hash is defined.
+#define i_use_cmp
#include <stc/carc.h>
#define i_type IPtr
#define i_key int
#define i_keydrop(x) printf("drop: %d\n", *x)
-#define i_cmp_native
+#define i_use_cmp
#include <stc/carc.h>
#define i_type IPStack
diff --git a/misc/examples/smartpointers/person_arc.c b/misc/examples/smartpointers/person_arc.c
index 38c883a7..11040cd2 100644
--- a/misc/examples/smartpointers/person_arc.c
+++ b/misc/examples/smartpointers/person_arc.c
@@ -31,11 +31,12 @@ void Person_drop(Person* p) {
#define i_type PSPtr
#define i_keyclass Person // ensure Person_drop
-#define i_cmp Person_cmp // specify object cmp, instead of ptr cmp for arc.
+#define i_use_cmp
#include <stc/carc.h>
#define i_type Persons
#define i_keyboxed PSPtr // binds PSPtr_cmp, PSPtr_drop...
+#define i_use_cmp
#include <stc/cvec.h>
diff --git a/misc/examples/sortedmaps/csmap_insert.c b/misc/examples/sortedmaps/csmap_insert.c
index c9f02891..04b8ddc6 100644
--- a/misc/examples/sortedmaps/csmap_insert.c
+++ b/misc/examples/sortedmaps/csmap_insert.c
@@ -13,7 +13,6 @@
#include <stc/csmap.h>
#define i_key csmap_ii_raw
-#define i_opt c_no_cmp
#define i_tag ii
#include <stc/cvec.h>
diff --git a/misc/examples/sortedmaps/multimap.c b/misc/examples/sortedmaps/multimap.c
index 1068a5dc..a4490f91 100644
--- a/misc/examples/sortedmaps/multimap.c
+++ b/misc/examples/sortedmaps/multimap.c
@@ -41,6 +41,7 @@ void OlympicLoc_drop(OlympicLoc* self);
// Create a clist<OlympicLoc>, can be sorted by year.
#define i_keyclass OlympicLoc // binds _cmp, _clone and _drop.
+#define i_use_cmp
#define i_tag OL
#include <stc/clist.h>
diff --git a/misc/examples/vectors/lower_bound.c b/misc/examples/vectors/lower_bound.c
index bea828f2..09cf2008 100644
--- a/misc/examples/vectors/lower_bound.c
+++ b/misc/examples/vectors/lower_bound.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#define i_key int
-#define i_cmp_native
+#define i_use_cmp
#include <stc/cvec.h>
#define i_key int