Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft of fixes needed for supporting variadic templates #111

Closed
wants to merge 1 commit into from

Conversation

anstadnik
Copy link

Hi, this pull request is a draft regarding #109.
So far it compiles and works when used with the variadic template, but it has some problems.
In particular, the problem occurs here. I haven't yet came up with a solution on how to separate variadic packs from the actual arguments. My guess would be to try to change this to something like:

#define dbg(...)                                    \
  DBG_MAP(dbg::DebugOutput(__FILE__, __LINE__, __func__)    \
      .print(DBG_STRINGIFY(__VA_ARGS__), __VA_ARGS__))

This way it will call the print separately for each argument, and in my head it looks somewhat similar to

template <typename... T>
void test(T&& ...args) {
  dbg('v', args..., 1);
};

int main(void)
{
  test(v, 1);
  return 0;
}

converting to

dbg::DebugOutput("potato.cpp", 42, "test")    \
      .print("v", 'v'), \
dbg::DebugOutput("potato.cpp", 42, "test")    \
      .print("args...", args...), \
dbg::DebugOutput("potato.cpp", 42, "test")    \
      .print("1", 1)

, and after that it will be processed accordingly in the print function.
It will require creating a DBG_MAP function for 2 arguments, but will make print function much easier, and will remove the need in hacks with initializer_list.

@anstadnik
Copy link
Author

Seems that I didn't really understand why you used a macro for getting types of variables. This change breaks it as it doesn't preserve the true type of the original variable, and instead outputs the type inside of a function.

@anstadnik anstadnik closed this May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant