Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8846195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:55:13+00:00 2026-06-14T11:55:13+00:00

I am creating a lua binding in C++11. I want to process each type

  • 0

I am creating a lua binding in C++11. I want to process each type in a variadic template.

I was thinking I could do something like this, except using Params... represents all of the types inside of it, and not a the next single type inside of it like variadic function parameters do.

template <class T, typename ReturnType, typename... Params>
struct MemberFunctionWrapper <ReturnType (T::*) (Params...)>
{

    static int CFunctionWrapper (lua_State* luaState)
    {
        for(int i = 0; i < sizeof...(Params); i++)
        {
             //I want to get the next type, not all of the types
             CheckLuaValue<Params...>();
             //Do other stuff
        }
    }
};

How would I go about doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:55:14+00:00Added an answer on June 14, 2026 at 11:55 am

    You can do this by simply expanding after the function call, into something that can be expanded to.

    // put this in your namespace
    struct Lunch { template<typename ...T> Lunch(T...) {} }; 
    
    // and this instead of the for loop
    Lunch{ (CheckLuaValue<Params>(), void(), 0)... };
    

    You can do something else with a lambda. You can even have your i incremented

    static int CFunctionWrapper (lua_State* luaState)
    {
        int i = 0;
        Lunch{ 
          (CheckLuaValue<Params>(), 
           [&]{ std::cout << "That was param " << i << std::endl; }(),
           ++i)... 
        };
    }
    

    Note that the Standard supports putting everything into the lambda. Compiler support until recently (last time I checked) wasn’t very good though

    static int CFunctionWrapper (lua_State* luaState)
    {
        int i = 0;
        Lunch{([&]{ 
           CheckLuaValue<Params>();
           std::cout << "That was param " << i << std::endl;
        }(), ++i)... 
        };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a class for a Lua binding which holds a pointer and can
Creating my WordPress author.php template page and ran into a little roadblock. I want
I am using luabind and I want to make this lua code work. print(hello..welcome
#1 Lua: local test = Test(); #2 C: //creating lua's test luaL_newmetatable(L, someTable); lua_userdata
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
Creating a browser based single-page browser based RIA. Would like to make use of
Creating extensions got much easier with Vs2010, but this seems not to be the
Creating a C# install package and I'd like on completed install for the Program
Creating a login system for something and am getting: Warning: mysql_result(): supplied argument is
I'm creating this simple program which would save me alot of time, but I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.