Skip to content

Cannot assign string to function that expects std::string_view #458

Description

@iwubcode
  • Compiler Used: Visual Studio 2017 15.8.4
  • Operating System: Windows 7
  • Architecture (ARM/x86/32bit/64bit/etc): 64bit

Expected Behavior

String in script should be passed to c++ function that expects std::string_view

Actual Behavior

Receive error:

Error: "Error calling function With parameters: (const string)

Expected: (const class std::basic_string_view<char,struct std::char_traits<cha
r> >)

Minimal Example to Reproduce Behavior

(some psuedo code based off of real example)

void do_something(const std::string_view& str)
{
  std::cout << str << std::endl;
}

// Later...
chaiscript::ChaiScript chai;
chai.add(chaiscript::fun(&do_something), "do_something");

// In chaiscript
do_something("Hi there");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions