diff options
Diffstat (limited to 'examples/sptr_music.c')
| -rw-r--r-- | examples/sptr_music.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/examples/sptr_music.c b/examples/sptr_music.c index fcb7a43f..04ec28cc 100644 --- a/examples/sptr_music.c +++ b/examples/sptr_music.c @@ -9,20 +9,21 @@ struct Song cstr title;
} typedef Song;
-Song Song_from(const char* artist, const char* title)
+Song Song_new(const char* artist, const char* title)
{ return (Song){cstr_from(artist), cstr_from(title)}; }
-void Song_del(Song* s) {
- printf("del: %s\n", s->title.str);
- c_del(cstr, &s->artist, &s->title);
+void Song_drop(Song* s) {
+ printf("drop: %s\n", s->title.str);
+ c_drop(cstr, &s->artist, &s->title);
}
#define i_val Song
-#define i_del Song_del
+#define i_drop Song_drop
+#define i_opt c_no_cmp
#define i_tag song
#include <stc/csptr.h> // define csptr_song
-#define i_val_ref csptr_song
+#define i_val_bind csptr_song
#define i_tag song
#include <stc/cvec.h>
@@ -31,9 +32,9 @@ void example3() c_auto (cvec_song, v, v2)
{
c_apply(cvec_song, push_back, &v, {
- csptr_song_new(Song_from("Bob Dylan", "The Times They Are A Changing")),
- csptr_song_new(Song_from("Aretha Franklin", "Bridge Over Troubled Water")),
- csptr_song_new(Song_from("Thalia", "Entre El Mar y Una Estrella"))
+ csptr_song_new(Song_new("Bob Dylan", "The Times They Are A Changing")),
+ csptr_song_new(Song_new("Aretha Franklin", "Bridge Over Troubled Water")),
+ csptr_song_new(Song_new("Thalia", "Entre El Mar y Una Estrella"))
});
c_foreach (s, cvec_song, v)
@@ -41,8 +42,8 @@ void example3() cvec_song_emplace_back(&v2, *s.ref); // note: calls csptr_song_clone()
c_apply(cvec_song, push_back, &v2, {
- csptr_song_new(Song_from("Michael Jackson", "Billie Jean")),
- csptr_song_new(Song_from("Rihanna", "Stay")),
+ csptr_song_new(Song_new("Michael Jackson", "Billie Jean")),
+ csptr_song_new(Song_new("Rihanna", "Stay")),
});
c_foreach (s, cvec_song, v2)
|
