by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Peter Repukat
@Alia5

nevermind...

something different though, are namespaces removed in v6.0.0?
I can still find it in the cheatsheet...

Jason Turner
@lefticus
they were added after 6.0
jhihn
@jhihn
Hey Jason, you're a really smart guy. I thought I knew C++ until I saw your videos. I was wondering though, have you ever thought about an automated tool to scan C++ code and "optimize" it? There's so much optional decorator stuff that could be applied automatically I think, like const, noexcept, references, etc. It would output full properly decorated code. Or is there something like this already? It's kinda like a linter but not.
Jason Turner
@lefticus
cppcheck will get you close. Nothing right now will tell you when something could/should be noexcept tho
and I don't know how hard it would be to write something that could detect that
jhihn
@jhihn
Well, I think you'd "just" have to scan all the things and know which ones throw exceptions, then back it up the hierarchy.
Thanks, I'll check cppcheck.
One annoyance I just discovered, because I work in multiple languages any given day, is the C++14 initializer syntax. Where JS uses var z = {} c++ is int z {6}. Not being able to use an '=' between the name and the value bugs me. And then there's "int x(6)" which would also be shared.
they look so close.
Jason Turner
@lefticus
jhihn
@jhihn
Hey yeah, I saw that in your videos. It's pretty amazing stuff.
Ooh I see what you mean. Was on mobile. Had to zoom in.
Jason Turner
@lefticus
it's not common usage, but it works the same way, as far as I can tell anyhow
Germán Méndez Bravo
@Kronuz
I'm having an issue using chaiscript since I started using string_view... I have a custom object which has operator[] receiving a string_view, and I configured a chaiscript class for that object in which I also added the operator "[]" to t_funcs
the issue is I'm getting an error when I run my script, saying it "Can not find appropriate array lookup operator '[]'. With parameters: (MyObject, const string)"
ans sure there isn't, as I declared (MyObject, string_view), but not the other one... now, in MyObject I can't declare both const std::string& and std::string_view, as it would result in ambiguities
how should I go about fixing this?
Germán Méndez Bravo
@Kronuz
got it! I just added a conversion from string to string_view
(sounds so obvious) :P
Stefan Agartsson
@Zephyrox_twitter
Guys I'm totally lost in ampersands, static casts, shared pointers and too much coffee! How can I add this method to Chaiscript:
template <typename T, typename... Args> std::shared_ptr<T> CreateComponent(Args... args)
It exists in Entity class
This is what I have come up with, but it doesn't work: chai->add(chaiscript::fun(static_cast<std::shared_ptr<DummyComponent1> (Entity::*) ()>(&Entity::CreateComponent<DummyComponent1>)), "CreateDummy1");
Stefan Agartsson
@Zephyrox_twitter
Never mind I'm an idiot, we shall never speak of this again!
Peter Taylor
@emersont1
hi, i'm not sure what i'm doing wrong but when i try to add a function that is a lambda i get a error: no matching function for call to ‘fun<std::__cxx11::string(bool)>( ... ::<lambda(bool)>) would me having the scripting engine as a unique_ptr cause this?
Peter Taylor
@emersont1
just from the cheatsheet example
Jason Turner
@lefticus
you need to show us what you're actually trying to execute
Peter Taylor
@emersont1

chai.add( chaiscript::fun<std::string (bool)>( [](bool type) { if (type) { return "x"; } else { return "y"; } }), "function_name");
Except for its to a unique pointer to the engine, not a stack instance. It works with class member functions, but lambdas give the no matching function error
Jason Turner
@lefticus
and then how are you trying to call it? You're getting the error when you call it, not during the add, correct?
oh, I see that's a compile-time error you'r egetting
Peter Taylor
@emersont1
Yeah, i should have explicitly said that
Jason Turner
@lefticus
just do this instead:
chai.add( chaiscript::fun( [](bool type) -> std::string { if (type) { return "x"; } else { return "y"; } }), "function_name");
much cleaner
part of the problem is that you were trying to expose a function returning const char * as a function that returns std::string
Peter Taylor
@emersont1
Okay thanks for your help
maniurobert
@maniurobert1_twitter

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour {
{
private Rigidbody rb;
private float moveSpeed = 5f;
public float sprintSpeed = 10;
private float currentSpeed;

public global::System.Single MoveSpeed { get => moveSpeed; set => moveSpeed = value; }

void Start()
{
rb = GetComponent<Rigidbody>();
currentSpeed = MoveSpeed;
}

void update()
{
    if (Input.GetKeyDown(KeyCode.LeftShift)) {
        currentSpeed = sprintSpeed;
    }

    if (Input.GetKeyUp(KeyCode.LeftShift)) {
        currentSpeed = MoveSpeed;
    }

    PerformMovement();

void PerformMovement()
if (Input.GetKey(KeyCode.W)) {
transform.Translate(Vector3.forward* currentSpeed * Time.deltaTime);
 } 
if (Input.GetKey(KeyCode.S)) {
transform.Translate(Vector3.back * currentSpeed * Time.deltaTime);
 }

if (Input.GetKey(KeyCode.A)) {
transform.Translate (Vecctor3.left* currentSpeed * Time.deltaTime);
 }

if (Input.Getkey(Keycode.D)) {
transform.Translate (Vector3.right* currentSpeed * Time.deltaTime);
 }

}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour {
{
private Rigidbody rb;
private float moveSpeed = 5f;
public float sprintSpeed = 10;
private float currentSpeed;

public global::System.Single MoveSpeed { get => moveSpeed; set => moveSpeed = value; }

void Start()
{
rb = GetComponent<Rigidbody>();
currentSpeed = MoveSpeed;
}

void update()
{
    if (Input.GetKeyDown(KeyCode.LeftShift)) {
        currentSpeed = sprintSpeed;
    }

    if (Input.GetKeyUp(KeyCode.LeftShift)) {
        currentSpeed = MoveSpeed;
    }

    PerformMovement();

void PerformMovement()
if (Input.GetKey(KeyCode.W)) {
transform.Translate(Vector3.forward* currentSpeed * Time.deltaTime);
 } 
if (Input.GetKey(KeyCode.S)) {
transform.Translate(Vector3.back * currentSpeed * Time.deltaTime);
 }

if (Input.GetKey(KeyCode.A)) {
transform.Translate (Vecctor3.left* currentSpeed * Time.deltaTime);
 }

if (Input.Getkey(Keycode.D)) {
transform.Translate (Vector3.right* currentSpeed * Time.deltaTime);
 }

} Nu stiu dece acceasta comanda nu mere , ma refer ce script e gresit , ma puteti ajuta sa faceti corect scriptu . Daca lai facut corect trimitetimi mail cu scriptu corect la maniurobert4@gmail.com

Jason Turner
@lefticus
@maniurobert1_twitter I'm not sure what programming language this is, or what your question is
Peter Taylor
@emersont1
hi, i don't know if this is an issue with chaiscript, but i'm getting an internal compiler error now
Jason Turner
@lefticus
@emersont1 hard to say, but if you're on the develop that now requires a C++17 compiler, and a pretty recent one
Peter Taylor
@emersont1
i'm on master, and i am using 17, let me double check all the configs
Jason Turner
@lefticus
Yeah that would be surprising to have an ICE there
Peter Taylor
@emersont1
right, it's minGW 8.1.0, it builds on linux. it's on 2e77b9
i'll try checking it out on develop
same issue
Peter Taylor
@emersont1
on MSVC i'm getting a ton of expression did not evaluate to a constant
(that's just on develop) it compiles fine on master