« first day (500 days earlier)      last day (2358 days later) » 

12:05 AM
So if I have a function Node firstNode(vector<Node> list) that returns the first to the list
and I do something like Node n = firstNode(mylist); n.x = 3;
will the x value of the first node in the list actually change
or will it not because the function returns a reference to a copy rather than the actual item?
 
nwp
@MalikBrahimi Not unless you have some sophisticated trickery.
You are copying the nodes, there are no references that I can see.
 
So if I can't change the function signature what would you suggest I do
 
nwp
What do you want to do? Why, for example, does firstNode exist at all when you can just use list.front()?
 
Well it's a vector
And it's not always the first that I need that was just an mvp to ask my question about references
 
nwp
If you want references you have to add them. Something like Node &firstNode(vector<Node> &list); Node &n = firstNode(mylist); n.x = 3;.
 
12:21 AM
yeah well I can't change the function signature unfortunately
Actually ... can I overload the function?
So that I have two signatures
Node firstNode(vector<Node> list)
AND
Node& firstNode(vector<Node> list)
 
nwp
So the goal is to make Node n = firstNode(mylist); n.x = 3; change mylist.front() without changing any of the code?
@MalikBrahimi Can't overload on return type only.
 
Well yeah tbh this is for a school assignment for an RRT algorithm
and there is a function that returns the closest node
But again it's a reference
 
nwp
Are you sure it's supposed to be n.x and not n->x? The latter would make much more sense and be easily implementable by making Node::x an int *.
 
Yeah ... it's a struct with int members
 
nwp
You can't change Node either?
 
12:26 AM
Nope
Would I just have to search the array for unique x,y combinations
vector rather
 
nwp
Is there anything you can change besides adding overloads for firstNode?
 
I think I just gotta play around and find a work around
now let me ask you this
do you know anything about bresenham's algorithm
 
nwp
I had to look it up. It's the line drawing thing.
 
nwp
I never quite understood why that needs to be a well known algorithm and isn't what every noob ever will do intuitively.
 
12:33 AM
As far as I see it increments X values while adjusting the Ys
That being said if you have two points (x1, y1) and (x2, y2) such that x2 = x1 + 1 for example and the distance between y1 and y2 is pretty large
 
nwp
It's not quite as easy because you want to be able to make vertical lines.
 
then we have a steep line ... the algorithm doesn't work for steep lines or even vertical
so ... that leaves me kinda confused
 
Oh ... so switch x and y and you're good?
 
nwp
In the case of a vertical line yes.
 
12:39 AM
would you just have bool quantifying what's steep like if abs(dy) > abs(dx)
 
nwp
Otherwise you might need to rotate by 90° or something.
 
ah okay thanks man
 
nwp
Rotating by 90° can be done by making x -> -y and y -> x in a way that you don't need to do expensive rotation computations.
 
sounds good thanks again
 
 
5 hours later…
5:22 AM
anyone here?
 
What's up
 
@MalikBrahimi How do you share lambdas across files? I have a set of global lambdas I want to share
They compose them like: Function f = g + h where + is overloaded
But the runtime is saying that f is not initialized. Why is that so if I've declared extern Function f; in the header?
 
uhhhhhh you might want to make function classes if you're gonna overload like that
 
0
Q: Why is my global, extern lambda variable not initialized at runtime?

VermillionAzureI am implementing parser combinators by composing C++ lambdas. For example: // rule_character.cpp #include "rule_character.hpp" LexerRule character_name = (make_terminal("alarm") & replace_with("\a") | (make_terminal("backspace") & replace_with("\b")) | (make_terminal("del...

@MalikBrahimi It's meant to model parsing combinators
 
Yeah sorry dude
I'm a Python guy lol
Java, C, C++ all follow haha
 
5:35 AM
...
lol
 
6:19 AM
@VermillionAzure Static initialization order fiasco maybe or some variant of it?
 
6:32 AM
Can anyone help me on below
How to represent java consumer at C++ side while using JNI?
I need to invoke a java method which takes java Consumer as input argument,and return callback on same object
My java code in java test application which I want same at C++ Side
Consumer<DemoAdapter> callbackLogin = demoAdapter -> {
if (webBrowser != null) {
webBrowser.stop();
}
};
Consumer<DemoAdapter> callbackLogout = demoAdapter -> {
if (webBrowser != null) {
webBrowser.stop();
}
};

// Create
AdapterConfig config = Builder.buildConfig();
//Constructor which I need to call from C++;Issue is with above to consumer.
keycloakAdapterApplication = new KeycloakAdapterApplication(callbackLogin, callbackLogout, config);
 
@wilx Not sure
 
@kunal A Java Consumer<T> is nothing more than an interface with one (and only one) method. So you have to write a class which implements this interface
Dunno if JNI allows you to write classes on the C++ side
 
6:53 AM
@wilx You're right
 
I guess you can write a Java class with a native method implementing that interface, implement that method from C++, create an instance of that class from C++, and pass it as the argument
 
I can not modified the java Code,If i could have been then your input was very correct. Consumer interface's accept method is not marke as native.
So even I can not use the RegisterNatives approach
 
7:13 AM
@kunal You don't modify existing Java code. You just add more of it.
The new Java code is written by you
The existing Java code is untouched
Let me repeat: write a new class, implementing Consumer through a native method
3
A: Is it possible to implement a Java Interface in C or C++ using JNI?

EugeneYes. Just as you do with any other native methods: class NativeRunnable implements Runnable { @Override public native void run(); } And now just use javah to create the header file and implement the function.

 
Solved it
 
7:56 AM
@VermillionAzure How? Don't leave us hanging!
 
@wilx Oh I answered the question
 
@VermillionAzure Oh, ok.
 
1
A: Why is my global, extern lambda variable not initialized at runtime?

VermillionAzureThe problem had to do with static initialization order. Since the lambdas often relied on each other already being initialized in a specific order, the initialization would not happen and the global lambdas would be left in an invalid state, thus causing the std::bad_function_call exceptions at r...

 
@milleniumbug Extremely Grateful for your time and inputs.My Constraints are, I got a jar from client,The code I pasted above is from the test class written to test the jar. Now same jar(client provided) we want to use from C++.So I am supposed to write the C++ code only. No java code.
 
Hmmm, that makes it indeed annoying.
I'm not aware of any way of writing Java classes from C++ code. If there is, you could use it.
But... can you make a second jar file with your Java code? And the second jar file will use the first one?
Don't know if that's possible
I only know the basics of JNI, but maybe it allows creating classes dynamically?
That would be another option if it's possible
 
8:21 AM
@milleniumbug This is very interesting solution(Creating second jar), I can consider this as the last option.It will definitely work. your basic know how of JNI is quite advance.Thanks a ton Sir.
 
9:03 AM
@milleniumbug you can use class loader to create new classes at runtime though I'm not sure it's the best plan
 
 
2 hours later…
10:54 AM
@ratchetfreak My nodes run through several processes: *creating the nodes in container *initialize the nodes *combine them together *hang in to root / scene graph...which means drawing. My question is, would you depict these stages in functions ?
 
whatever is easiest
 
Ron
11:24 AM
For a Win32 project I am keeping all constants and hardcoded window identifiers in separate namespaces. Should I do the same with my functions, wrap them in a namespace?
Or leave them be in a source file because C-ish WinAPI.
 
Namespaces are for organisational and naming conflict avoidance purposes. Your functions in your source files are unlikely to conflict with C functions (thanks C++ name mangling), they may conflict with the other functions you possibly define in your project
 
Ron
I see.
What would you do? Seems a bit verbose to wrap them too.
 
If all the contents are local to the source file, you can use anonymous namespace
I probably wouldn't bother with this in an application project, at least, not until the first naming conflict
 
Ron
Many thanks.
 
OTOH, if a library doesn't put its functions in a namespace, it's negligence
 
12:07 PM
how can i conceptual sum up ->> create, init, combine ?
 
 
1 hour later…
1:30 PM
"setup" sounds good
 
nwp
Which might be the same thing as a constructor.
 
yes nwp, construct is also good but i will take setup.
 
nwp
No, I mean the setup should be implicitly done in the constructor. It avoids problems like forgetting to set something up.
 
1:53 PM
o.k. i do the most of this stuff in the initializegl method....setup my scene container and the scene graph but other things are"created" at runtime on the base of user interaction...like the creation\drawing of a new primitive. this is in the case of an scene graph a new parttree which is added.
 
 
2 hours later…
3:36 PM
Hey, anyone got any experience with parts of the Eigen libraries not loading? I'm using Eigen/Dense for `Vector3f` and I'm now trying to use Eigen/Geometry for `Quaternionf`. The compiler is just acting up saying Quaternionf is not a member of Eigen (in Eigen::Quaternionf).
Is there any incompatibility between using multiple parts of the Eigen libs in one file?
(Compiling, as before with CMake with `find_package(Eigen3 REQUIRED)` and `include_directories(${EIGEN3_INCLUDE_DIRS})`)
 
nwp
Looks like you forgot #include <Eigen/Geometry.h> or something similar.
 
my first though exactly, but I've got these two in the same header file giving me the compile errors: `#include <Eigen/Dense>` and `#include <Eigen/Geometry>`
(If I put a ".h" the compiler says it can't find the file)
Btw. why is my code here not formatting correctly? The FAQ says
`code`
which is what I'm doing...
 
markdown is disabled on multiline messages
 
nwp
Hmm, according to the documentation you are doing it right.
 
@milleniumbug Wow... ok...
 
nwp
3:44 PM
If you have an IDE you can probably CTRL+click on Eigen/Geometry which should open the header and you can search for Quaternionf and see if it is there or hidden behind a macro or some other trickery. But it should just work.
 
Ok, now things are getting weird. Things only seem to break because I'm using the Quaternionf in boost::circular_buffer<Eigen::Quaterninonf> meas_quat_;
Works fine if I use it by its own. And still, the message says "not a member of Eigen"...
 
4:15 PM
@Pronex #include <Eigen\Eigen>
thats all...dont change the directory structure of the eigen archive when you unpack
 
@FerencRozsa What do you mean by that?
 
it needs the Eigen subdirectory
 
@FerencRozsa Sadly, it didn't help.
 
you code with vs ?
 
No Sublime on linux.
 
nwp
4:23 PM
Try clang and see if it gives you a better error message.
You did #include <Eigen/Geometry> before declaring boost::circular_buffer<Eigen::Quaterninonf> meas_quat_;, right?
 
set include directory in your project dependencies to the main "eigen" directory and then in the header <Eigen\Eigen> not these direct incudes <Eigen/Dense> etc...
 
Ok, will try. Never used clang before, but I'll take a look at it and will keep you in the loop.
 
Eigen is pretty crap with it's include files though, many don't have a .h extension so they conflict with the std lib
 
it needs these directory structure ->> (your decision)/Eigen/...
 
and add (your decision) to the include search paths
 
4:37 PM
exactly
 
@ratchetfreak Wait is this where Eigen is in my system? I.e. /usr/include/boost/numeric/odeint/external/(eigen)
Btw. including Eigen/Eigen would only include "Dense" and "Sparse" (in usr/include/Eigen3/Eigen/Eigen; not whatever I wrote before)
But Dense contains Geometry, ok. My bad.
 
you set your include search path to usr/include/Eigen3/Eigen and then in your header <Eigen\Eigen> thats all
Or better, it needs as search path the directory, where the Eigen subdirectory is sitting.
 
4:56 PM
Both done. So I opened another, smaller project which I can use to test and have these two lines directly together:
Eigen::Quaternionf quat = Eigen::Quaternionf(0, 0, 0, 0);
boost::circular_buffer<Eigen::Quaterninonf> quatc;
The first one works, the second doesn't with "Quaternionf is not a member of Eigen". So I'm thinking this is not a problem with Eigen but maybe with boost?
 
nwp
Just for experimentation's sake try boost::circular_buffer<Eigen::Quaternion<float>> quatc;
Wait wait wait. You just misspelled it.
Quaterninonf
 
Eigen::Quaternionf
 
You're not serious? OMG. copy paste is a hell I can't get out of (And sublime text only does completion on what I already wrote so...)
 
Way to go. Or how to lose hours of your life and motivation on a holiday... Thanks guys!
 
nwp
5:04 PM
Consider using an IDE that can do actual code completion. Qt Creator for example.
 
:-) these guys here are amazing
 
Isn't that really focused on using Qt though? And how does it compare to CLion? My main problem with IDEs in my current project is the use of ROS (Robot operating system) ... CLion showed me a lot of errors which just were ROS and Catkin (Cmake wrapper) things...
 
Nov 17 at 20:37, by milleniumbug
there are many IDEs, none of them are great, but some of them suck less than others
 
@milleniumbug Speaking directly out of my heart.
 
right qt creator is my opinion better than vs.
 
nwp
5:11 PM
@Pronex It supports non-Qt projects. And as long as you don't use C++17 features and use the clang code model it will generally work decently well.
It even supports some cool tricks from sublime text like Shift+Alt+Down to get multiple cursors.
 
Hmm... I guess I should give it a try then...
Next time, when I'm too demotivated to begin with the next big chunk of coding ^^' (seems lika a nice break)
 
nwp
If you care about cool stuff you need to know to press Ctrl+K.
 
 
6 hours later…
11:11 PM
@nwp in some editors that is "kill line"
 
nwp
I'm sure you can change it if it bothers you.
 
11:59 PM
is there a way to treat a function lambda, or address, with custom parameters as a variable ?
 

« first day (500 days earlier)      last day (2358 days later) »