« first day (498 days earlier)      last day (4679 days later) » 

user406009
05:00
How about having elements with set sizes, and some with variable sizes?
I already got that far
user406009
Equal splitting of greedy variable sized objects?
user406009
Pretty much your recursive binary division idea.
who said anything about equal?
the division's place is arbitrary
hell, it wouldn't work at all if you could only split each region into two equally sized regions
user406009
You are right, a weighted system is probably better.
05:05
the problem that I'm currently attempting to grapple with is how to express it
I don't want the user code to have to do the layout algorithm, but I also don't want to limit the expressions you can use to produce the layout
user406009
By default have the weights be one. Space is first factored out for static objects. The remaining objects share the space they have left. Then each of the objects divide the space inside their child objects.
there's no such thing as a default weight
the entire way in which layout is actually achieved is in having non-equal weights
user406009
I would think layout would be more determined by the alignment within the grid boxes themselves.
user406009
Similar to gtk's or qt's series of vertical and horizontal boxes, the weights usually do not need to me modified, as long as X object is above and to the right of Y object, or vertically alligned with Z object, etc.
mostly, I'm just struggling with how to express the concept in code
given the size of the current division, return a value which says how far along each side to split
std::function<Math::AbsolutePoint(Math::AbsolutePoint)> layout;
user406009
05:15
It would be simpler if you only had one dimensional splits.
what, if you could only split along one axis?
user406009
Yeah. That's what gtk does.
then how would I express any user interface layout which is anything other than a line of elements in the other axis? I'd only be able to control their layout in one dimension
user406009
You have an a box of boxes. Sort of like a two dimensional array.
which would basically be the same as allowing splitting in both dimensions
user406009
05:18
I still think the logic for splitting in one dimension is simpler.
user406009
step 1: find widths of all sized elements
step 2: subtract width from total width
step 3: find sum of weights
step 4: divide leftovers by sum of weights
step 5: know you know the size of all objects (known width or weight* dividedPart)
user406009
Sort of like divide and conquer.
Ok, one more:
> Assume that day is an int variable whose value is 1 or 2 or ... or 7. Write an expression whose value is "sun" or "mon" or ... or "sat" based on the value of day. (So, if the value of day were 4 then the value of the expression would be "wed".).
I've tried:
user406009
Split one hard problem into many easier problems.
@Moshe Array lookup
05:24
I know, that doesn't work. Looks like they want a nested conditional operator.
wtf, that's bullshit
why on earth would anyone use anything other than an array lookup for such a task?
you could use a hilarious combination of std::vector and boost::assign perhaps
ok, final question
the UI layout mechanism now appears to own all my UI elements
that can't be good
user406009
day == 1 ? "sun" : day == 2 ? "mon" : day == 3 ? "tuesday" ...
user406009
Don't we all love the tertiary operator?
no
I cut it from Wide
also, doesn't that kind of chaining require parenthesis?
user406009
Yeah you are right, precedence is going to kill me.
user406009
05:29
Also, why not use shared_ptr's for your design?
user406009
If you actually want the things to live independently.
that's not really going to help, because they still won't die when the UI mechanism has the last reference
but I guess that actually, that's not a calamity for me
user406009
You want to remove your elements from the gui when they die in your game code?
I mean, if you wanted to change layouts at run-time or something
after all, you could just find and destroy the GUI's reference
@DeadMG What's wrong with owning here? Own & clone if you have to.
user406009
05:32
IIRC Qt did a unique_ptr type thing where a parent widget owned the child widget.
user406009
Gtk did actual reference counting.
@EthanSteinberg Qt has the shittiest ownership design ever in the history of holy crap it's bad
raw pointers everywhere
@LucDanton Ah, you're right.
I already include a "hotswap" mechanism for swapping UIs if necessary
I've seen some people recommend writing/using a clone_ptr, too.
nah
I think unique_ptr will be fine
it's a UI element, it lives in the UI, that's fine
user406009
@DeadMG Are you still going to try to write a 2 dimensional space divider?
user406009
05:36
Just wondering how it would work.
user406009
(Thinking back to how hard 2d bin packing was compared to 1d bin packing)
but I'm not trying to pack a bin
if you want empty space on your UI that's really none of my concern
user406009
06:01
0
Q: How to find the length of the string which also contains string terminating character in between. Example: ABC\0ABC

user1168582How to find the length of the string which also contains string terminating character in between. Example: ABC\0ABC. Is there any inbuilt function present which returns the length? If the Input string is: ABC\0ABC Output: 8

user406009
Someone not using std::string and suffering for it.
^ Comments?
I think I found out why I couldn't flag one of the comments. Apparently when a comment is already flagged, the flagging menu disappears.
give me a sec, it's a long train
seems to me like TheBuzzSaw was being a dick, but I don't see anything in twsaef which was offensive or trolling
as far as I can tell, he only ever asked you to clarify and expand upon your position
06:18
well, in his first comment he called names, "it's fundamentally incoherant" (sic). and he claimed "You haven't explained this in your answer; you've just asserted that doing so avoids risk and bugs", which was untrue.
but it's not personal to you
he only ever suggested negative things about the answer
right, i agree. still my troll-detector reacted to that. the other guy, the one who made the first comment with lots of UPPERCASE SHOUTING, did go personal though.
yeah, he was quite a dick
06:42
You've stared at the Usenet abyss for too long I think.
07:25
0
Q: Are Java2D and Swing examples of Good Use of OOP?

IntermediateHackerOverusing Inheritance ? Java Swing and Java2D rely a lot on inheritance. Most people have told me I should avoid inheritance as much as possible and only use it when necessary. So is the extensive use of Inheritance in Java2D and Java Swing justified? Adapter Pattern I have heard a lot of prai...

Java has no other programming techniques, so they can't make any API work without over-using inheritance
yeah.
but what about the singletons?
you have to ask?
there's no such thing as a well-used singleton
08:03
Hi. I am reading "the JSF air vehicle C++ coding standards." and I don't understand Rule 2: "There shall not be any self-modifying code." What does self-modifying code mean?
code which changes itself during execution
can anyone help me out here ?
@IntermediateHacker Can I say horrifically disgusting code?
As an example, consider a program that on its first run transform itself into a Hello World. So on first execution nothing happens, and on the second you get "Hello, World".
@DeadMG yeah. I already know that.
08:05
also, reinterpret_cast<void*>(obj);
ok, thank you
@IntermediateHacker There's no reason you shouldn't use std::vector<element> instead of std::vector<element*>, is there?
@LucDanton yeah, thanks.
also, calling it a linked list is pretty silly when it's actually an array
why is j returning 0?
it should be returning 5. :'(
08:10
There's no need for reinterpret_cast by the way, static_cast is correct here.
oh, I get it.
changed to static_cast.
You want to static_cast stack[index].object, not stack[index]. That's one error caught thanks to static_cast!
oh yeah. thanks, again.
You can store a std::type_info const* as a 'type token'. I.e. &typeid(foo) to get the unique token associated with the type of foo.
(C++11 brings std::type_index which is a wrapper around std::type_info const*.)
is that supported by ideone C++0x ?
08:16
I doubt it.
damn, I'm getting a runtime error.
(Note that you compare two tokens by dereferencing, e.g. *stack[index].type == typeid(obj).)
The reason you store a pointer in the first place is that std::type_info is non-copyable and reference members are undesirable.
And this is why std::type_index was introduced. Very convenient e.g. for maps.
yeah. it would have made life easier in this case.
but I'm still getting the runtime error. :'(
08:20
A more recent paste please?
*j dereferences a null pointer.
meaning?
oh, I see.
int* j = 0; defines j with a null pointer value.
*j dereferences j and that's bad and you should feel bad.
I feel guilty. :(
but doesn't list.get_element() set j s destination to i ?
08:25
If you don't know, why did you write the function in the first place? :)
What do you figure void foo(int i); int i = 0; foo(i); does to i?
I see.
okay, it works now!
@LucDanton Zoidberg has the answer!
but the typeid's aren't matching. :(
Hurray! Somebody noticed Zoidberg! (\/)(;,,;)(\/)
@IntermediateHacker Da cooooode.
who's Zoidberg?
It's alway the same link actually. you just have to refresh it.
08:32
@IntermediateHacker Doctor Zoidberg!
lol.
10 mins ago, by Luc Danton
*j dereferences j and that's bad and you should feel bad.
@IntermediateHacker You store the type information of obj, which has type T*. Later on, you retrieve the type information of type T, but you probably want T*.
I see.
It works!
@LucDanton thanks.
I wonder if I should have used a hashmap instead of the element struct.
08:38
how about just std::vector<boost::any>?
I doubt ideone has boost.
but I can do it with g++.
I think it does, actually
interesting read on exercise's effects on glycogen levels in the brain:

http://well.blogs.nytimes.com/2012/02/22/how-exercise-fuels-the-brain/
@IntermediateHacker For reference my version would look something like this.
@LucDanton damn, you did it better in less code. I'm horrible. :'(
08:46
Well I piggybacked on what you already did.
you can typedef thinks inside a class?
Classes can have data members; member functions (static or otherwise); struct, enum and union members but also member types.
using iterator = T*; is a valid implementation of std::vector<T>::iterator.
(Equivalently typedef T* iterator;.)
@LucDanton I also included your version in the blog post. is that okay?
Yes.
45 mins ago, by DeadMG
also, calling it a linked list is pretty silly when it's actually an array
is there any support for atomic STL containers in gcc? std::atomic_int seems to work fine under testing, but I can't seem to find any equivalent for std::vector<>, for instance...
08:58
there is no Standard support for any high-level concurrency
only the lowest level mutex, etc
@DeadMG - thx - I'll write a quick wrapper (easy) - just prefer to use std/already-written software whenever possible...
IIRC libstdc++ wants to add support for std::atomic<T> with arbitrary T (non-integral etc). However you can't rely on std::atomic<std::vector<T>> to be supported by everyone (it's conditional or something, unlike the integral types). More to the point though, the interface of std::vector<T> is such that std::atomic<std::vector<T>> would not be very useful.
yeah, you'd really need a specialized interface
> There is a generic class template atomic<T>. The type of the template argument T shall be trivially copyable (3.9).
@LucDanton I suspected the first part of your comment to be true, but why would the an atomic interface to std::vector<> not be be useful? Is it because it would depend on context?
09:02
Nevermind, std::atomic<std::vector<T>> is straight out an extension.
@kfmfe04 Because std::vector has many non-concurrency-safe interface elements
@kfmfe04 For instance you need to guarantee a minimal number of elements at all times, otherwise you can't access anything. And you can't access anything outside of that minimum.
simply pushing and popping into such a vector would be the least of your problems
@DeadMG but, like any thread-UNsafe data-struct, if I overwrap the interfaces with a mutex, it should work fine, right?
no
that never works in a real situation
for a start, you get deadlocks, and secondly, lock-all-the-things is horrifically performance degrading
and thirdly, it's sequences of operations which have to be thread-safe, not just each individual one
09:06
...one step at a time - get it working first - one lock on the specific one may be slow, but it should work, I would think
there's no good proving that there's a fifth element in the vector and guaranteeing it when you get a reference to it if as soon as the lock is released, someone else pops it off and then you de-reference that reference
no, it won't work at all
@kfmfe04 Hum, I wouldn't have thought that using std::atomic<std::vector<T>> would look similar to locking + using an std::vector<T>.
@LucDanton - I'm open to either solution (or any one which would work...)
you need a specialized container
TBB and PPL offer them
@DeadMG stl has value-semantics - when I take the element off, it would be copied already...
09:07
@kfmfe04 std::vector offers many places where it's reference semantics
not to mention the fact that the container itself is referenced
@kfmfe04 I tend to prefer high-level solutions but it's not like I've ever written anything multithreaded.
if you call pop(), there's no guarantee at all that there is an element to pop, even if you just checked the size
@LucDanton - I too, prefer, high-level solutions... ...however, I wrote my app before there were high-level solutions (it was previously based on Pthreads - recently converted to std::thead) - seems to work fine (passes drd, helgrind, etc...)
@DeadMG - I understand that, when there are threads running helter-skelter, without locks...
no, even if you lock every individual member function
I will try it out with a lock and see what happens... ...see if I get sporadic results or if drd/helgrind complains (it hasn't with a locked deque<> I wrote during the days of pthreads...)
the point with locks is, from the STL's internal perspective, it can't tell if I'm running one thread or 10 threads...
09:11
it doesn't matter if drd or helgrind complains
the only thing you'd have proved is that you didn't write a test case in which you managed to exhibit the bad behaviour
not that such a case doesn't exist
@kfmfe04 But it's not the STL's internal perspective that matters.
to make a std::vector safe, you would have to lock every sequence of operations, not every individual operation
I can never prove that a case doesn't exist for any algorithm...
non-trivial algorithm...
or, re-design the interface from scratch
any non-trivial algorithm isn't non-deterministic like threading is, it's a totally different kettle of fish
you can't just put in a few sample inputs and say "Well, it's probably good now", because that's just not what happens in concurrency
well, if you can come up with a case which SHOULD fail, I would gladly try it out!
let it run for a little while
@DeadMG ty - I will try it out and report a little while later - have to hop out of the coffee shop in a moment - will report back in 3-4hrs
@DeadMG but I see your problem with the thread2 implementation already - that block needs to be atomic - I would have to wrap it inside one atomic call
09:17
exactly my point
simply throwing a lock on the std::vector won't actually protect you
but that's not hard to do, at all - just need to be careful
I plan to write a safe interface
with an internal vector member
so in other words, you'd be completely re-designing the interface from scratch
which is what I just said had to happen
13 mins ago, by DeadMG
and thirdly, it's sequences of operations which have to be thread-safe, not just each individual one
I understand your and Luc's comment comment now! And why atomic containers would be non-trivial to work out in the generic template case - I will proceed to write a safe wrapper class...
My "AHodgePodgeWinApiAndOpenCvProgram" at the Lounge now displays a pic! Wow! The next step, to display continuous cam video, will probably involve implementing threading...
^ Irony, in case anybody wonders.
09:21
@kfmfe04 Impossible to work out in the generic case, actually.
well, possibly not impossible if you only accepted a container in the strictest Standard sense
you would have to know the exact specification of absolutely every member function
sbi
sbi
09:43
@sehe On your profile page, look at the tags you have participated in. There it lists the number of posts and the score. Um. Wow. Apparently, I had that wrong! This isn't the rep, it's the score
@EtiennedeMartel For most CS professors I have met, any template-related question beyond the most simple ones would be obscure enough to throw them off. You might have to provide us with some more details, though, if you want meaningful answers.
10:42
10
Q: Why is the constructor not called when () is used to declare an object?

Lazer$ cat cons.cpp #include <iostream> class Matrix { private: int m_count; public: Matrix() { m_count = 1; std::cout << "yahoo!" << std::endl; } }; int main() { std::cout << "before" << std::endl; Matrix m1(); ...

Why so many upvotes for just another most vexing parse question?
@FredOverflow: Please stop adding back the [most-vexing-parse] tag to questions that aren't about the most vexing parse. Thanks.
sbi
sbi
@CharlesBailey [tag:most-vexing-parse] ==> :)
Imagine writing a parser for the Dutch language. So many ambiguous sentences.
sbi
sbi
How many of you have dropped a hobby project after three months, losing interest? This guy spent three years modeling Lego pieces and using them for creating an animation for a useless video of some Lego celebrity. Sometimes I think we are just too impatient with our side-projects.
For example, "Jan eet een appel." is already ambiguous.
@sbi I often drop projects already after a few hours.
10:55
0
Q: Why does moving a pointer variable not set it to null?

FredOverflowWhen implementing move constructors and move assignment operators, one often writes code like this: p = other.p; other.p = 0; The implicitly defined move operations would be implemented with code like this: p = std::move(other.p); Which would be wrong, because moving a pointer variable does...

@CharlesBailey If you're talking about the question that Fred pasted link to, it is indeed just a Most Vexing Parse question.
I added the tag back.
No it's not. A a(A()); is a most vexing parse. A a(); is just a slightly vexing parse.
@CharlesBailey Pretty silly distinction for private terminology.
I've already fixed the tag wiki for most vexing parse to reflect this. It matches Scott Meyers original use and the wikipedia entry.
Do we really need two different terms for that? :)
10:59
@CharlesBailey Revert it, please. Don't invent new terminology. Especially not impractical silly distinctions like that.
No. I don't really think we need to call X x(); anything.
Most vexing parse has come to mean something quite specific.
Do I need a Firefox plugin to spell check stack overflow posts, or do I just need to activate it somewhere?
@CharlesBailey That's bullshit, but possibly Scott Meyers' bullshit. However, it has proved practically impossible to make him correct errors :-(.
Do you have link to Scott Meyers' statement(s) about this?
I'm sorry, I thought Scott Meyers was first person to use that phrase.
I don't have a copy of the book to hand, unfortunately.
I've always understood that the original usage of "most vexing parse" refers to declarations where initializers that could be interpreted as temporaries or parameter declarations cause the whole declaration to be ambiguous, not the more trivial fact that you can't use empty parentheses as an initializer in a simple object declaration. stackoverflow.com/questions/1610551/…
11:14
Another Cat!!! @AnthonyReflected .
mawning
I'm really tired and grumpy today
didn't sleep enough
@sbi, I"m joining you in the grumpyiness :P
I've removed the disputed paragraph from my tag wiki update. I'm not alone in my views, though. See comments to this answer: stackoverflow.com/a/8596349/19563
Assertion failed: (((enum OpArgMask)((luaP_opmodes[(((OpCode)(((i)>>0) & ((~((~(Instruction)0)<<(6)))<<(0)))))] >> 2) & 3))) == OpArgK - great illustration for macro evilness =(
11:32
jeez that's a complicated macro
looks like Lisp with all the parenthesis
Hello guys. jsfiddle.net/tt13/5CxPr/53 please press "new" how can I prepend and slidedown?
@TheCoder what?
@jalf prepend and slidedown tr. have you taken a look at the link?
this is a C++ Lounge and you're asking questions about web CSS stuff?!!!
WTF
sorry
11:35
post a question on stackoverflow.com
is it me, or Vs2010 slow?
@DeadMG back now - yup, I agree - STL's API is at too fine a granularity to be "thread-safe" - was thinking about it some more...
it's not just too fine granularity
@TonyTheLion both.
it's also the way in which they'll dish out references which you couldn't possibly guarantee remain valid
especially for e.g. iterators
@DeadMG - yes, I agree (was thinking about those cases too) - my wrapper class will be extremely restricted (perhaps only 5-10% of STL functionality)
11:42
oh
is C++ AMP basically a layer over things like NVidia's CUDA?
it's a layer over DX11's Compute shader
ooooooooooooh
clang status page says lambdas are in svn
can i include a vector as a member of a class?
yep
would be kind of useless if you couldn't
any type can be a class member
11:52
@jalf except the type defined by the class ;)
@FredOverflow shush, you ;)
But one could probably say "Any complete type can be a class member".
how do i implement it? vector<int>myvector::Class ?
and incomplete types, while we're at it
@JonathanDewein what do you mean?
11:53
or define it
class MyClass
{
    std::vector<int> myvector;
};
@JonathanDewein There's no need for that. Members are defined at the site of first declaration. It's never an issue.
class Foo { std::vector<int> myvectormember; }
You forgot the semicolon after the class definition ;)
damnit
11:54
What is it?
I even took the super-ballsy move of copying the DLLs into my Windows system folders and replacing the ones that were there
i kep getting errors
but D3D still isn't working
now I have no error but also no debug spew
@JonathanDewein Did you #include <vector>? Did you put std:: in front of vector?
error: 'vector' does not name a type
11:55
Can we see the line where myvector is defined?
ah, i needed to put std:: ....
@JonathanDewein well, there's a reason we used std:: in the above answers ;)
i thought i didn't need it if i was including namespace std
but i guess you do in the header still
You were talking about testing and nobody mentioned QuickCheck? For shame.
@JonathanDewein #include != using
11:57
@JonathanDewein Never put using namespace std; in a header file. It's called "namespace pollution", and it's a very bad thing to do.
@CatPlusPlus Is QuickCheck Haskell-only?
so anyway, LAMBDAS IN CLANG?
There are implementations for other languages.
There's QuickCheck++.

« first day (498 days earlier)      last day (4679 days later) »