« first day (463 days earlier)      last day (2393 days later) » 

5:30 AM
how do write an algorithm that tells me im on certain coordinate
points
for example if i was on a 2x2 board
the coordinates i would want to check is (0,1) (1,0) (1,2) (2,1)
for a 3x3 board it would be (0,1) (0,2) (1,0) (1,3) (2,0) (2, 3) (3,1) (3,2)
i have to figure this out for a mxn board
 
6:20 AM
6 messages moved from Lounge<C++>
 
Ron
@milleniumbug Appreciate it.
 
6:58 AM
@Brogrammer it can't be 2x2 board if it has 0, 1 and 2 as coordinates.
 
 
2 hours later…
8:29 AM
@ratchetfreak (i know you mantain the graphic room) i code on a machine where windows 7 is running on vmware. supported is opengl 2.1 and glsl 1.2. my problem is, that when i run my program my particular models are not rendered. i see only the background in my openglwidget. i draw my models with glDrawElements....i think there is the problem but it is supported from opengl 2.1 so its diffuse. when i try it on my home computer all is working like expected.
maybe you have a hint
GPU Shark v0.10.0
(C)2013 Geeks3D - www.geeks3d.com
----------------------------------------
- Elapsed time: 00:00:30
- Windows 7 64-bit build 7601 [Service Pack 1]
- OpenGL info:
- GL_VERSION: 2.1 Mesa 10.0 (git-96c7e2b) (# ext: 140)
- GL_RENDERER: Gallium 0.4 on SVGA3D; build: RELEASE;
GPU 1 - VMware SVGA 3D
- GPU:
- Device ID: 15AD- 405
- Subvendor: Unknown (15AD- 405)
- Driver version: 8.14.1.24
- Bios version: n/a
- GPU memory size: 384MB
 
there are a lot of potential issues that could cause models to not be drawn,
 
i have checked if maybe the buffer objects arent created but they are there....
 
8:52 AM
maybe because the gpu is just virtual....so when i work with buffer objects and gldrawelements this caused the problem
 
that shouldn't matter TBH
 
nwp
@FerencRozsa The graphics functions should all have some sort of error reporting. Something like glGetError which you should check after every function (I made a check_OpenGL_error(); function for that). Once you have that it should be easy to find which call failed.
Usually it is because you used a function that is not available in that version of OpenGL or the graphics driver is outdated and buggy.
 
9:08 AM
hm all o.k. no errors...->0
 
nwp
Did you try it in the VM too?
 
9:39 AM
glBegin() and glEnd() is working..insane
 
are you using a shader? if so check the infologs (both compile and link)
 
10:20 AM
they both compile without error.
 
10:32 AM
and how do you set up the attributes?
 
11:26 AM
Anyone good with using opengl etc?
1
Q: 3D FPS Camera in OpenGL

rshahSo I've got a basic FPS camera working which can move around the 3D space. Having trouble with physics but thats not why I'm here! So the code below creates a scenegraph which contains torus model objects, and I can move around in the space using the keys and mouse movement. #include <iostream>...

 
 
1 hour later…
12:30 PM
Hello everyone! I'm not sure why my compiler complaints about the assignment of a reference of type of the base class to an object of derived class. the templates are defined too and are exactly the same, also NoSwapStorage is public derived from ISwapPolicy: ISwapPolicy<_KeyType,_ValueType>& refToSwapStorage = NoSwapStorage<_KeyType,_ValueType>();
 
1 message moved from Lounge<C++>
 
@Robert What will the reference point to once the temporary object is destroyed?
(Conversely, why do you have a reference if you do not have a object to refer to)
 
@sehe the NoSwapStorage should be an object to a SwapStorage which just does nothing. (empty load and store methods). I'm trying to assign refToSwapStorage which is a member in another class to NoSwapStorage. But it fails to compile saying: "error: could not convert ... from ... to ..." not sure if the full error message would be helpful
LRU_Cache( size_t capacityInBytes,
ISwapPolicy<_KeyType,_ValueType>& refToSwapStorage = NoSwapStorage<_KeyType,_ValueType>()
)
 
it's as a default arg...
 
@Robert So, your default argument "refers" to a temporary value. That can't work. (Well, actually, MSVC might accept it, but that's non-standards-compliant)
@Robert If you need that, temporaries can only be lifetime-extended when bound to const&. And even then the lifetime is only extended till "the end of the containing full expression" (which is probably enough for the function call UNLESS you make the mistake of passing along/storing the reference)
LRU_Cache(size_t c,
ISwapPolicy<_KeyType,_ValueType> const& refToSwapStorage = {})
But the name does imply it must be a ref and it cannot be a const& so, overload!
struct X {};

void foo(X& scratch_area) {

}

void foo() {
    X scratch_area;
    foo(scratch_area);
}
 
12:53 PM
@sehe the snippet I posted about the LRU_Cache is the constructor (didn't wanted to post everything ^^). So the lifetime of default arguments is temporary? So cannot be assigned to a non-const reference?
 
@Robert Yes, though the lifetime of default arguments isn't special. It's the lifetime of T(); that's temporary.
@Robert Yeah, that (it being the constructor) makes it more dangerous, because the chance is higher that the reference be used outside the constructor. There's all manner of tricks, but really you should redesign the class to be explicit about it's optional user-supplied swap-storage (boost::optional<T&> ref_to_swap e.g. or just std::unique_ptr<T> ptr_to_swap or even T* ptr_to_swap = nullptr depending on the ownership semantics)
 
@sehe well I have some setup-unit which sets up the swapstorage (path to swap dir nothing much). swapstorage and cache are bound to this unit which sets up both of them. swap first and then passes the swap to the cache-unit. I could use unique_ptr there for transfering ownership over to cache from the setup-unit. Thx for the discussions and answers :)
 
 
2 hours later…
3:04 PM
@ratchetfreak where to place a bounding voulume calculation? As part of the node, that has the property an particuar bounding volume or just as an static global function ?
 
 
2 hours later…
5:12 PM
After finding Qt annoying due to following different practices than "modern C++", I've started finding some really well-designed things about it. My favorite atm is how if you want to use QSomeObject, the #include is just #include <QSomeObject>. You just copy-paste it there. I've been thinking about this for how it could be really useful for libraries in general.
If you want to use ns::some_object, you'd #include <ns::some_object>, except we can't do that because : is forbidden in file names on Windows. So it'd be #include <ns/some_object.hpp> (with or without the .hpp, it doesn't really matter). But I've started wondering about functions as well. This pattern doesn't seem to make as much sense for functions, but I really like how the header is so obvious for objects
Like if I wanted to use std::transform, if I'd just #include <transform> rather than having to know that it's part of <algorithm>
It does seem too much to have a header file for every single function, though...
 
so basically there's no organisational unit which a free function would naturally fit into
you could put some of them into a namespace and then tell people to "if you want to use the function in the namespace A::B, #include <a/b.hpp>", but that doesn't work well
 
Yeah. If the free function is associated with a type, it makes sense to just have it in the header for that type. But for parts where the free function is standalone and is what's interesting, idk. Something for me to think more about
 
headers are the most annoying part of C++ for me lately
to increase modularity I should have most of my code inside a source file, but I can't put templates inside source files or otherwise they won't be easy to use
 
Yeah. I really want modules.
 
the syntactic annoyance of repeating myself twice is minor in comparison
at least if you do it right, it's just a matter of correcting your code in case you changed the code in one place but forgot in the other, because the compiler will complain
now, even if we disregard the part about needing to have templates inside a header, if I need to call the code inside the template, I need to include that header too
some header files are notoriously bad for their macros
 
5:27 PM
Yeah..
I have a small problem in that I keep up-to-date on the new features / future features. And then I want them now. A lot of these features might come in C++20, but many also will come in C++23 or later.
 
windows.h defines a max(a,b) macro, some of the header on linux defines major(x) and minor(x), and something in Apple headers does #define nil nullptr
 
nwp
I think "macros have to go" is the only thing about modules that everyone agrees on.
Besides that it will solve all problems.
 
I don't exactly agree that macros should simply be removed. I think the preprocessor should be phased out. But there are a few cases where macros are extremely helpful. Token-based macros aren't that nice though. Proper use of macros basically points to deficiencies in the language
 
nwp
They don't want to remove all macros, they just say that #define int double\nimport some_module will not affect the ints in some_module.
 
Yep
@Justin FWIW, I wouldn't be too surprised if when modules come in, all you had to do is import qt and then forget about it, because the compiler is supposed to handle whatever is pulled in. There'd be no need to think about how you have to #include the correct file. Or maybe modules will have a different design, who knows.
 
nwp
5:39 PM
It never bothered me that much to #include the right thing. The code duplication is much more annoying.
 
nwp
5:54 PM
std::cout << "Hello World"; is not guaranteed to print "Hello World"?
 
this sounds wrong
OTOH, the guy's profile info says
> C++ expert, standard library implementor. Project Editor for the C++11 International Standard. Author of The C++ Standard Library Extensions, which covers TR1; now obsolete.
 
nwp
I can only find that std::ostream's destructor calls std::basic_­ostream​::​sentry's destructor which calls os.rdbuf()->pubsync() and who knows what that does.
 
I believe he should be able to provide with relevant wording then if this is not the case
> if *this is the last instance destroyed, flushes the default C++ streams
> The header <iostream> behaves as if it defines (directly or indirectly) an instance of std::ios_base::Init with static storage duration: this makes it safe to access the standard I/O streams in the constructors and destructors of static objects with ordered initialization (as long as #include <iostream> is included in the translation unit before these objects were defined)
 
nwp
Thanks, I'll point that out and ask.
 
6:21 PM
oh here's an answer
@nwp -- I didn't say it doesn't get flushed. But for the underlying issue, see the C11 standard, 7.21.2/2: "Data read in from a text stream will necessarily compare equal to the data that were earlier written out to that stream only if: ... the last character is a new-line character." — Pete Becker 8 mins ago
 
nwp
I just read that too.
So it's guaranteed to get flushed, it just may not be read/written. I don't get it.
 
The full paragraph is as follows
> A text stream is an ordered sequence of characters composed into lines, each line
consisting of zero or more characters plus a terminating new-line character. Whether the last line requires a terminating new-line character is implementation-defined. Characters may have to be added, altered, or deleted on input and output to conform to differing conventions for representing text in the host environment. Thus, there need not be a one-to-one correspondence between the characters in a stream and those in the external representation. Data read in from a text stream will necessarily compare equ
I assume this paragraph exists because there was a popular implementation which didn't print the contents not terminated with a newline character
 
nwp
It doesn't even seem to say what the terminating new-line character is required for. For the last line to be printed? For anything to be printed? For the program to not be UB?
 
I interpret this as "it is implementation defined whether a sequence of characters that doesn't end with a newline is a text stream"
 
My vs2015 have a built-in github
Now I want to delete that CMake.sln
Can anyone give some hint?
I have to say this toy hard than command line..
 
6:37 PM
what happens if you right click it?
@nwp now, the reason why that paragraph is relevant is because of 27.4.1.1
> The header <iostream> declares objects that associate objects with the standard C streams provided for by the functions declared in <cstdio> (27.9.2), and includes all the headers necessary to use these objects.
 
Nothing happen..
Just this two options.
It is usless for deleting it
 
nwp
Try selecting it and pressing delete?
@milleniumbug This is too much over my head. I'm not used to standardese.
 
@nwp Then nothing happen..
 
nah, that paragraph basically ties the C++ and C standards
 
Strange, you are all in c++, but you don't use vs?
 
6:43 PM
I do, but I don't think I've had that problem before, as I don't use git inside VS
as far as I can see, this is just a "recently opened projects" list
 
Maybe you mean here
If you don't use github, how to manage your code version?
 
I use git from the commandline
that said, I'm currently running MSVS2015 and I'm trying to make more than one project appear in that list you have
 
:-)
the logic of this built-in github always make me headcache..
 
oh, I know, this shows all the .sln files you have inside your local git repository
 
@milleniumbug It exists largely because of a thread long ago on comp.lang.c, when some asshole pointed out that in C89, there was no guarantee that the transformations applied when writing a text file were reversed when reading it, so you could plan on writing data out, and being able to read the same thing back in.
 
6:51 PM
@milleniumbug yes, I know, and know I want to delete a specify one.
 
@JerryCoffin ...wow
@yode try finding it in the file explorer (that is, in your local repository) and remove it there
 
@milleniumbug System will give a error information say this directory is opening..
You can do it directly?
@milleniumbug That works.Thanks..
 
good :)
 
Another and the laster confusion..Could we add a existed solution into this list?
I note I click the open directly button, it will creat another local rep
 
13 mins ago, by milleniumbug
oh, I know, this shows all the .sln files you have inside your local git repository
so that would be a matter of putting another solution in that repository
 
7:06 PM
as your hint, I just use file explorer..
 
@JerryCoffin I do not get it. Care to explain?
 
Thanks very very much. Good night~ @milleniumbug
Oh god. it will bee a invalid directory wich cannot open and commit to rep..
 
7:28 PM
@milleniumbug This question can be solve?
 
 
1 hour later…
8:34 PM
@EuriPinhollow Sure. If you write something to a file, and read it back in C89 doesn't guarantee that the two match (at all). C99 added this clause to say: okay, here's at least some minimal guarantee--you can write it out, and assuming each line ends in a new-line, when you read it back in, you'll get the same thing as you wrote out.
@milleniumbug All stemmed from an argument over what (how much) useful code you could write that fit within the C standard's definition of "strictly conforming" (I.e., output didn't depend on any undefined, unspecified, or implementation defined behavior). I took the position that the answer was: "nothing--you can't do anything useful at all with strictly conforming code."
You can't write to a file, because the pre-opened streams (stdin, stdout, stderr) are all text files, and there's an implementation defined mapping from what you write to what goes in the file. You can't open another file, because the strings you can successfully pass to fopen are implementation defined. You can't even return from main because there's an implementation defined mapping from what you pass in the return statement to what value is returned to the OS.
 
nwp
That's pretty daunting.
It almost feels like implementation-defined languages have an advantage here, but all they do is say "Well, it works if you try it" which is also true for C and C++.
 
@yode dunno
 
8:51 PM
@nwp Yeah--I certainly wan't trying to argue that C and C++ are useless. I was mostly arguing that the definition of "strictly conforming" was so narrow that it was useless. The C standard also defines a weaker "conforming", but it just said something to the effect of: "code that is acceptable to at least one conforming implementation".
 
A malicious implementation can deliberately make all the implementation defined constructs to have the most useless implementation
 
That meant that if somebody added a #pragma fortran, which let the C compiler accept Fortran source code, then Fortran source code became conforming C code. I'd have to check to be sure, but I believe they added a requirement that conforming C at least couldn't violate any rules that required a "diagnostic".
@milleniumbug "Welcome to Hell++".
 
to some degree this already happens: MinGW has a buggy std::random_device, libstdc++ chose std::minstd_rand for std::default_random_engine and MSVC (and probably MinGW too) can't open files if the pathnames can't be represented in the system locale
the last one has a reasonable explanation why (backward compatibility), it's just it's silly from a perspective of a person creating a new project: new programs require workarounds for standard functionality
 
9:16 PM
@milleniumbug Almost all of it has rational explanations. Some is sort of handy, and some extremely useful--but it still makes it impossible to really guarantee portability. Nearly any guarantee you might want to make carries some caveats.
 
10:04 PM
Hi. Is it good practice, during declaration of enum class, to explicitly assign some values to particular enumerators, and use them later in the code through cast?
 
> to explicitly assign some values to particular enumerators
ooookaaaaaayyyyy
> and use them later in the code through cast
....whhyyyyyyyyyyyyyyyyyyyyyy
@Toreno96 What is the problem you're trying to solve
 
10:18 PM
@milleniumbug Suppose we have class Card representing playing card, where enums represents suits and values, and we want to calculate how much points (in any game, it's not important now) is worth given card. While I know it is possible using switch or probably constexpr if in C++17, wouldn't it be good idea to use the fact that enumerators can have explicitly defined values and that it is rather safe to cast them using static_cast<int>?
 
one issue that immediately comes to my attention is that if two cards should be different, but they happen to have the same number of points, this won't work
 
Why?
 
because the comparison Foo::Bar == Foo::Baz will be true
you can always just do enum class Foo { Bar, Baz, Spam, Eggs }; std::unordered_map<Foo, int> whatever_to_points_map = { { Foo::Bar, 40 }, { Foo::Baz, 40 }, { Foo::Spam, 30}, { Foo::Eggs, 20 } };
also if there is more than one property that you can map to your enums, it doesn't make sense
(because why do I need to call y_from_whatever(value) to get y and static_cast<int>(value) to get x)
 
I didn't know that enumerators with the same underlying value are treated as the same during comparing. Thx.
 
it's for choosing how it's represented in memory and for serialization
it's also an easy way to make an alias
 
10:34 PM
@JerryCoffin that's what I understood but I cannot understand what reversing order of changes is about.
@JerryCoffin freopen tho.
 
@EuriPinhollow Not about reversing the order of the changes--just reversing the changes (or, perhaps, inverting would be a better word). I.e., whatever changes you do on output get undone on input, so what you see being read back in matches what you wrote out.
@EuriPinhollow Has the same problem as fopen: your still specify the file as a string, and the allowable content of that string is implementation defined.
 
nonono, see:
https://stackoverflow.com/questions/1598985/c-read-binary-stdin/1599093#1599093
It blocks your path differently though:
>It is implementation-defined which changes of mode are permitted (if any), and under what circumstances.
 
@EuriPinhollow Well, it prevents you from changing mode (but the implementation defined restriction on the path still exists as well).
Even if you could switch to binary mode successfully, an implementation defined number of null bytes might be appended to what you write to a file in binary mode, so you still don't avoid implementation defined behavior (though, in fairness, it does restrict its scope at least a little bit).
 
10:50 PM
Well, it's not in the C89 draft. )
I mean, the "NULL as fname".
 
@EuriPinhollow Right--I believe that part was added in C99. Bottom line though: whether you use it or not, you end up with implementation defined behavior.
 
let us not forget of the implementation defined mapping of input to source code character set :D
 
11:40 PM
@milleniumbug I wish I could forget it... :-)
 
11:52 PM
Writing about this again got me to looking for at least one of the old threads. It's a little scary looking back--one thread went on for well over a month...
 

« first day (463 days earlier)      last day (2393 days later) »