« first day (262 days earlier)      last day (2815 days later) » 

08:30
Hi guys
is there any difference between a constructor defined as
MyConstructor(Type1 x1, ..., Typen xn):mx1(x1),...,mxn(xn) {
  //Other stuff;
}
and
MyConstructor(Type1 x1, ..., Typen xn):mx1{x1},...,mxn{xn} {
  //Other stuff;
}
(curled bracket vs parenthesis)
yes, one uses "uniform initialization syntax" and the other doesn't
which means?
I'm seeing that it has been introduced with c++11
in few words?
it doesn't seem to me any different from the other one
(for the constructor context)
or could I maybe do something like
No nothing...
I was about to make a boo-boo
AFAIK, the difference is in aggregate initialization in the {} case; and () will do direct init, without it
(honestly never bothered to look at this topic, since we heavily use boost and C++ pre-11 :( )
08:41
same here
by aggregate
you mean like
initialize more members using the curly brace
it's an official term for making interviews longer :D
like one of the members where a struct
I could do something like
mx1{y1,y2,...,yn}
08:42
ye exactly
ok that's the thing then
but I suggest you reading ↑ link to make sure you won't do any UB stuff
it's not too long
calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs,
s.flag); cameraMatrix is intrinsic parameter how i take extrinsic parameter?
«intrinsic» in English means an object is inside of something, «extrinsic» means an object is outside of something
how cameraMatrix is defined? is it a member variable of this Camera class?
nwp
nwp
@AlexCerry did you read the docs?
@nwp many many times.
@nwp i really tired to read this document again and again.
nwp
nwp
08:49
and the part where it talks about extrinsic parameters didn't make any sense to you?
@nwp i know what is extrinsic parameters.
But do not know how to get it.
nwp
nwp
> Note, that if intrinsic parameters are known, there is no need to use this function just to estimate extrinsic parameters. Use solvePnP() instead.
@nwp i use calibrateCamera function to get intrinsic parameter then?
suddenly it's an OpenCV question now :D
nwp
nwp
@AlexCerry Can you try to state what you actually want to do? What data do you have and what data do you want to get?
08:53
@nwp i understand i just confuse myself. meaning i use solvepnp and get rvec and tvec correct?
and this two are extrinsic parameter correct?
nwp
nwp
@user8469759 mx1(y1,y2,...,yn) would also work. There is something about value initialization, i{} initializes to 0 for int i while i() doesn't. Then there is something about narrowing conversions, like i(3.14) being ok while i{3.14} is not. But I'm fuzzy on the details and probably get some of them wrong.
Ok, I'll have a proper look
I posted code in code review exchange and a guy said I should change the constructor
he proposed an implementation with the curly braces
so I was trying to understand the difference
@nwp but rvec and tvec is 2 column.
if some other guy would tell you to jump out of the window, would you do it? :) try to think for yourself first, read the docs at least
but its must to 4 x 4.
08:58
@login_not_failed that's what I said...
nwp
nwp
@AlexCerry I don't really know, the docs say "Output rotation/translation vector" and I have no clue if that is the same thing as extrinsic parameters.
@AlexCerry you know what the fields in that 4x4 matrix mean? Some fields mean translation, some mean orientation(rotation). Some are always the same. Maybe you can build your own from that data.
@nwp problem is rotation matrix.
its only 1 column and 4 rows.
sorry, 1 column and 3 rows.
But in doc they say r11 .... r33.
nwp
nwp
that 4x4 matrix is probably a quaternion
@nwp it's not "probably", it should be a quaternion
@AlexCerry is this 1×3 matrix made by you or is it a standard one?
@login_not_failed 1 x 3 matrix is given by opencv function calibrateCamera.
@nwp can you explain in simple words.
09:07
rotation matrix is a single transformation for a given vector: you can do rotate, skew, scale all at once by one matrix multiplication
instead of doing all of these actions separately, you apply one matrix multiplcation once — that's why it is being used so widely
nwp
nwp
@AlexCerry It is the mathematical way to represent rotation, translation, scaling and something of 3D objects. You can make a matrix that moves a point to somewhere and another matrix that rotates a point somewhere and when you multiply them you get a matrix that moves and then rotates.
@nwp i understand. But why i getting 1 x 3 why not 3 x 3.
nwp
nwp
@AlexCerry is that for the translation?
@nwp no rotation.
nwp
nwp
then it is probably something like "rotated around X, rotated around Y, rotated around Z", which then leads to gimple lock which is why people use quaternions instead
I don't know, it should say somewhere what format it is in. If it doesn't you can try to make simple examples to figure it out.
09:14
@nwp that is whole image rotation matrix correct?
not just one pixel.
@AlexCerry rotating one pixel is something you would never see in 3D-related tasks, so no
nwp
nwp
@AlexCerry i don't understand the question
@nwp the rotation matrix give by cameracalibrate is whole image current rotation position correct?
nwp
nwp
@AlexCerry That doesn't sound right because rotating an image in 3D space which is the result of a camera calibration doesn't make any sense to me, but I'm not familiar with opencv so I don't really know.
@nwp no problem thank you for your help.
09:23
@nwp I'm guessing he actually has a quad, which has an image texture applied to it, so all of the permutations happen to this quad, because otherwise it's a complete nonsense
@login_not_failed i doing calibration.
i need to create 3d map. So i need points coordinates.
details of your actions are too vague to be really sure what you are really trying to do…
@login_not_failed 3d construction.
 
5 hours later…
14:54
@nwp s/gimple/gimbal/. Gimple are the people who sell PC-Lint (and used to have really cool ads showing obscure bugs that PC-Lint would detect).
nwp
nwp
oops
well, wikipedia got it right at least
15:16
Should I be using getopt in C++ 11?
getopt is a C library, there's like 4534858378092587 different ones for parsing arguments
@milleniumbug so is that a yes or a no? and if a no which is the standard for C++ 11?
there's no "standard"
Well whats the recommended one then?
it's a simple choice - do you not like getopt? don't use it
15:19
Is using getopt in a C++ 11 program advisable?
ScY
ScY
void
heapsort(heap,n)int *heap,n;
{
Ell
Ell
nooo
ScY
ScY
hmm
im bad at posting code
wtf is this: void functionname(arglist) variables {...}
nwp
nwp
@ScY ctrl+k, I mean don't post code here
ScY
ScY
15:21
I guess so
@ScY very old C-style function signature
in general any C library won't integrate as well as their C++ ports so it's your choice pretty much
ScY
ScY
sry you can remove that
@ratchetfreak ah ok thx
is it still valid c?
argument parsing is such a thing everyone does on their own so it's unlikely there will be one that's "recommended"
no idea but no-one sane would every code that way still
15:22
@JoshuaBarnett That depends on whether it does what you want done. I'd generally treat it as legacy, but I'll openly admit that's largely personal preference (i.e., I just don't like it much).
it doesn't have type safety
14 messages moved from Lounge<C++>
I usually prefer to parse arguments "by hand". If a program has enough arguments for this to be clumsy, chances are pretty good that you're overdue for improving the design (and yes, I realize that's saying essentially all gnu stuff is way overdue for better designs). For programs where lots of flags/options are nearly unavoidable, I'd consider Boost Program Options.
jrh
jrh
15:58
Not sure if you guys use cmake a lot or not, but could somebody explain where SDL2 for names would be defined? Is it just a string variable?
find_library(SDL2_LIBRARY
  NAMES SDL2
  HINTS
    ${PC_SDL2_LIBDIR}
    ${PC_SDL2_LIBRARY_DIRS}
  PATH_SUFFIXES x64 x86
)
2 messages moved from Lounge<C++>
everything in cmake is strings
Usually you'd like to use find_package instead, find_library seems to be lower level
jrh
jrh
is it looking for the string literal "SDL2" or some variable called SDL2 containing some other string, though?
@milleniumbug good to know, thanks, this is in something I didn't write though. I'm trying to keep my changes as minimal as possible.
> A cache entry named by <VAR> is created to store the result of this command.
jrh
jrh
16:03
that's the output of find_library though, I'm looking for NAMES, i.e., "The name of the library that is searched for is specified by the names listed after the NAMES argument. "
haven't read the manual througly, but I'm guessing it's looking for a specifically named file in several directories
jrh
jrh
so I guess SDL2 is a variable, I think I sort of figured it out
nah
if it was a variable set somewhere else, the command would use ${SDL2} to evaluate the variable so it would expand to the value it contains
it's a string literal
jrh
jrh
So you can have string literals in cmake without ""?
jrh
jrh
16:07
time to do some reading then... that puts a lot of this in perspective
tbh with the rigour the CMake language it's defined, I wouldn't be surprised if it's a magical unicorn
jrh
jrh
oh geez
does it have hard coded builtins? Is it possible it's pulling in a canned SDL2 profile or something?
it's a bunch of commands slapped together really
cmake probably started simple but then things needed to be added and without a singlular vision you just get a mess
kindof like php
@jrh I doubt that
16:12
there is a find package directory in the cmake install which describe how to find various libs which includes SDL2 but that works only for find_package I believe
jrh
jrh
does cmake maintain a list of directories that common libraries reside? E.g., "GTK+ is usually at path X on Windows", etc.
yeah, find_package is slightly magical
first it tries to find a library you choose by passing in paths, if you don't do that, it tries to find "config scripts" (a.k.a. pkg-config approach) which are provided by distros, and then if it fails, it tries the "finder scripts" which try to guess the paths things are commonly installed at
but find_library seems to be not
it just searches the paths you provide and then the common dirs like /usr/lib and like, if fails, it fails
it contains a list of find*.cmake in the install dir which describe how to get a package in the install dir
yes, these are the finder scripts for find_package
jrh
jrh
wow... that's a lot of find scripts. There is one for SDL. There's a lot more to cmake than I originally thought.
(note that this project uses find_package in other places so this is still useful to know)
16:19
oh, CMake documentation calls what I've called "config scripts" as "Config-file Packages", and what I've called "finder scripts" as "Find Modules"
jrh
jrh
I didn't realize it at the time but the file that my snippet was from was intended to be a custom find module for SDL2 because I guess cmake didn't write one yet (they have one for SDL 1, but not 2)
it's possible that the SDL find module is for both SDL1 and SDL2
jrh
jrh
SDL2 is one of those releases that renamed a lot of directories
the built in SDL find script appears to contain SDL1-isms
Also in an unrelated note I think I figured out why the repo says it needs MinGW... pkg-config. Well, mystery solved guys, thanks!
I was hoping I could rip the MinGW requirement out of it to make the setup easier to understand for a friend of mine but it looks like it's not going to be that easy. Also apparently the dev totally broke MinGW compatibility according to recent commit messages.
 
3 hours later…
19:42
I had a discussion with my lector, and its main point was that the following assertion in foo can be passed or not, depending on compiler.
/* g++ -S address_of_const.cxx -O0 -masm=intel -traditional-cpp -pedantic -Wall */
/* g++ verison 5.4.1 */

#include <cassert>

const int i = 0 ;

void foo ( const int& i )
{
/* cmp QWORD PTR [rbp-8], OFFSET FLAT:_ZL1i ; note : symbol of ::i */
assert( &::i == &i ) ;
}

int main ( )
{
// mov edi, OFFSET FLAT:_ZL1i ; passing parameters. note : symbol of ::i
not just doubts, but i cannot find direct arguments from standard.
20:05
@GreenTree Why do you have the assembly comments and references. Remove those if they aren't related to your question.
#include <cassert>

const int i = 0 ;

void foo ( const int& i )
{
assert( &::i == &i ) ;
}

int main ( )
{
foo( i ) ;
}
can't really provide any standard references, but I'm fairly sure your lector is wrong, at least in this case
nwp
nwp
somewhere in section 3.4 name lookup
20:32
no, that is not about name lookup.
but i will check it anyway.
will not be surprised if it's there.
nwp
nwp
I think I just misunderstood the question, ignore my comment about name lookup
nwp
nwp
20:49
the question is, in foo(i), does the parameter bind to i or create a temporary to bind to or is either one allowed?
5.2.2.7 says *"Where a parameter is of const reference type a temporary object is introduced if
needed (7.1.7, 2.13, 2.13.5, 8.3.4, 12.2)."*. One just needs to look through these cases and decide that no, it is not needed, and therefore no temporary is created and the assertion must hold.
12.2 would be most likely to allow the creation of a temporary.
thank you.
nwp
nwp
> Temporary objects are created
...
(1.2) — when needed by the implementation to pass or return an object of trivially-copyable type (see below)
this might be what your lector was referring to
I don't know what "see below" means, because there are 1298 pages below that remark and I don't know if there is a scope restriction to "see below".
jrh
jrh
Is this the literary equivalent of an access violation? Maybe just a page fault.
21:16
but how can it be passed to a function, if in function i can check and do whatever i want with i's and parameters addresses and expected semantics must be kept. for example
for ( auto i : { &some_const , &global_const , } ) if ( func( * i ) ) { } etc.
nwp
nwp
I think you should ask a question on SO
there should be a clear answer because you should be allowed to const_cast the const away and then it matters if it is a temporary or not
I would not expect the standard to leave that unspecified
 
2 hours later…
22:54
Hey guys, I just had a quick question about std::advance. I'm currently using it to select a random element from my vector, and was just wondering if that coudl cause issues. one of my buddies says it could potentially cause me to go outside of the vector?
pastebin.com/eP1TrB6e example of what im doing
It can go outside of the vector if your distance parameter goes outside
Gotcha. In the case of my example, I feel it's fine, but he continues to disagree with me on whether or not it could cause a problem.
Now, i do know i can end up with duplicate element values this way of course,but im clearing that up by writing a function that finds and replaces those elements with different values.
With C++17 you could use std::sample instead
@Jeff you pretty much need to ensure your container is bigger than player count
otherwise Bad Things™ will happen
gotcha. yeah the container will always be bigger than the playercount, otherwise the match will be on hold. when the match is on hold, none of these functions are going to be called
23:10
Also rand() is bad for many different reasons
yeah i normally dont use rand anymore, but since each stage has a max of 24 players, i figured it'd be fine in this case
seems a little unnecessary to use a twister or somethign like that for such a small number
it's not only about number quality, in fact, it's the smallest issue
If you like, you may try C++11's <random> instead
also: std::advance(it, n) is no different from it += n when it is a random access iterator (like std::vector<T>::iterator). It only matters in case when it is not a random access iterator, in which case advance will do ++it n times, and the latter will fail to compile
(failing to compile is a good thing if you don't intend your algorithms to become O(n^2))
i guess i could utilize randoms abilities o replace rand yeah, wouldn't be hard.

« first day (262 days earlier)      last day (2815 days later) »