Giter Site home page Giter Site logo

Comments (4)

satoren avatar satoren commented on May 15, 2024

I'm sorry, i dont understand.
Can you write example code?

from kaguya.

Sygmei avatar Sygmei commented on May 15, 2024

For example if we have a simple function which add two things :
template<typename V> V addStuff(V a, V b) { return a + b; }

That I can use like the following :
int a = addStuff(3, 3); std::string b = addStuff((std::string)"foo", (std::string)"bar"); std::cout << a << std::endl; //Display 6 std::cout << b << std::endl; //Display foobar

I can't do that in kaguya :
kaguya::function(addStuff);

I can do this :
kaguya::function(addStuff<int>);

But I'll have to specify each type I want to use, is it possible to pass the entire function and use all the possible types in Lua ?
Either by using kaguya::templatedFunction (or something like this), or some overloading of kaguya::function (Same for addMember, addMemberFunction etc..).
I don't know if C++ allows to do this.

from kaguya.

satoren avatar satoren commented on May 15, 2024

Can not it. Instantiate of C++ template is compile time only.
When you invoke function from Lua, type determine runtime.

That you can is below only.

kaguya::overload(
//List the type that might be used
    addStuff<int>,
    addStuff<std::string>,
    addStuff<my_class>,
    addStuff<my_other_class>);

from kaguya.

Sygmei avatar Sygmei commented on May 15, 2024

I understand :) Thanks anyway !

from kaguya.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.