Skip to content

How can I place nothings in a list and filter them out? #19

Answered by Hirrolot
UndarkAido asked this question in Q&A
Discussion options

You must be logged in to vote

This will do the trick:

void func(
#define field(TYPE, NAME) ML99_JUST(field<TYPE> NAME = {})
#define exclude_field(TYPE, NAME) ML99_NOTHING()

ML99_LIST_EVAL_COMMA_SEP(ML99_listMap(v(ML99_maybeUnwrap), ML99_listFilter(v(ML99_isJust), ML99_list(Fields))))

#undef exclude_field
#undef field
        ){
}

Expansion:

void func(
field<std::string> name = {} , field<std::string> fact = {} , field<std::string> comment = {} , field<std::string> desc = {}
        ){
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@UndarkAido
Comment options

@Hirrolot
Comment options

Answer selected by UndarkAido
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants