« first day (352 days earlier)      last day (4599 days later) » 

10:06 PM
What do you think about explicit constructor syntax?
 
It's a must!
Constructors and conversions should be explicit by default.
And you'd have an implicit keyword instead.
 
Is that so =)
 
I know that some of the other regulars agree with that.
And I lost count of how many times I got bitten by forgetting to make a constructor explicit.
 
Is it possible to create a private template but then typedef it and make them global?
 
Hmm, can you show an example of what you mean?
 
10:16 PM
sure
template<class T> struct generic_vec2
{
    T x,y;

    generic_vec2() {}

    explicit generic_vec2(T v)
    {
        x = y = v;
    }

    generic_vec2(T _x, T _y) : x(_x), y(_y)
    {}

    template<class U> explicit generic_vec2(const generic_vec2<U> &v) : x(v.x), y(v.y) {}
};


typedef generic_vec2<float> vec2;           // vector2d <float,float>
typedef generic_vec2<int>   vec2i;          // vector2d <int,int>
typedef generic_vec2<bool>  vec2b;          // vector2d <bool,bool>
I want the typedefs to show only
so that it's not possible to create any other generic_vec2
 
I see. But why?
What's the problem?
 
so that you can only create correct vectors
I'm loosing connection all the time..
 
Er, if the code works, they're correct, no?
Say, wouldn't generic_vec2<double> be fine too?
 
they are correct, but it's now possible to create generic_vec2<some_random_class>
which I do not want
 
Sorry if I'm being a pain in the mikta but what's wrong with that?
If my random class provides the correct behaviour...
 
10:22 PM
Because I want to limit my vectors to ints, bools and floats
 
Well, that sounds like a completely arbitrary and unnecessary restriction, but here's something you could do: ideone.com/Aswnw
 
this was the question I was looking for
http://stackoverflow.com/questions/7372024/allocation-of-memory-c-compile-time-run-time
 
Thanks, but in what way is it unnecessary? It limits the programmer to only create the vectors that are legit.
 
Why isn't generic_vec2<double> legit?
 
In this case, double is too high precision
 
10:28 PM
Too high precision? How does that make it less "legit"?
 
I don't understand how statics can be allocated memory at compile time however
 
(And in case you don't know, double can have the same precision as float)
Can you imagine how it would be like if std::vector<double> was not allowed?
 
Since it's gonna be used for GPU's, and they are optimized for floats, I do not see why one should be able to create vectors of doubles
 
And yet, std::vector only allows types that are legit.
 
Call it legit, inappropriate or whatever
 
10:31 PM
Oh, but I can see why! First, some GPUs are starting to support double precision. And secondly, can't I use it for something else?
 
I don't want to use it for something else, even if I add doubles, I don't vectors of other things =)
and if I want to use it for something else, I could add a new typedef
 
"I don't want to use it for something else", then don't use it.
 
@RMartinhoFernandes can you please explain what this guy means...I'll post the code and then what he says after
 
Well, it's up to you to decide. It's just that I'd be very unhappy if I couldn't use a template with a type that meets the requirements because the author thought my type wasn't good enough :)
 
class Primes
{
    static int[] knownPrimes = new int[4] ;
    static
    {
        knownPrimes[0] =2 ;
        for(int i=1;i<knownPrimes.length;i++)
             knownPrimes[i] = nextPrime() ;
}
}
 
10:40 PM
Oh, that's Java, right?
For a moment there, I was about to reply "that doesn't even compile".
 
Then he says "What if a static initializer in class X involves a method in Y but Y's static initialzers invoke a method in X to set up its static values? This cyclic static initialization cannot be reliabky detected during compilation because the code for Y may not be written when X is compiled
 
And what is confusing you?
 
What the hell that does that mean....yeah it is Java :)
If cycles happen, X's static initializers will have been executed only to the point where Y;s method was invoked. When Y, in turn invokes the X method that method runs with the rest of the static initializers yet to be executed
 
Still never found a very "good" solution to my access violation problem in DirectX
 
Right.
And that's bad.
 
10:45 PM
This isn't a Java lounge by the way
 
what the hell is happening to the room? It disconnects me, doesn't send my msg...:S
@RMartinhoFernandes any idea what the cycles is?
@IDWMaster well aware of that :)
 
@IDWMaster Seems like I'm the only owner around, and I'm ok with it. Yeah, I'm pulling rank :)
@LewsTherin Lemme craft an example.
 
@RMartinhoFernandes thanks
 
Speaking of managed languages; is C# interop with native code supposed to be faster (using WinRT) than it was with P/Invoke?
 
AFAIK WinRT uses COM.
Dunno how fast that used to be, but it's probably faster than P/Invoke.
 
10:48 PM
A version of COM which Microsoft claims has been optimized for use with managed languages
Why is it faster than P/Invoke? How are they different?
 
Oh well, in that case, it is supposed to be faster. Let's see how it turns out.
 
Personally; I do a lot of C#/C++ interop and haven't noticed any delays using either method, so I don't really get what the big deal is in the first place, but Microsoft claims that WinRT is supposed to be a lot faster than their previous models of P/Invoke and regular COM
I'm assuming that P/Invoke may be slightly slower because it has to do a symbol lookup on the first call to each function
After that it should be just as fast as native calls though I'd think.
 
There's marshalling.
 
@IDWMaster What is your AV problem in DX?
 
1
Q: Access violation in DirectX OMSetRenderTargets

IDWMasterI receive the following error (Unhandled exception at 0x527DAE81 (d3d11_1sdklayers.dll) in Lesson2.Triangles.exe: 0xC0000005: Access violation reading location 0x00000000) when running the Triangle sample application for DirectX 11 in D3D_FEATURE_LEVEL_9_1. This error occurs at the OMSetRenderTar...

Why did it double-post
Ok. Now the double-post disappeared. Strange.
Only happens when I use compatibility mode D3D_FEATURE_LEVEL_9_1.
 
10:53 PM
Weird, it did double-post.
 
This is essentially one of Microsoft's own sample apps
 
But only one got oneboxed...
 
Is there a way to report bugs on the chat system?
 
Tough I wouldn't do it without it being easily reproducible.
 
I got disconnect again bloody hell
 
10:55 PM
what is wrong when it doesn't compile in codepad.org?
 
curious, by the way
those ComPtrs are supposed to have template arguments
 
@AlfPSteinbach Bad compiler?
 
it seemed ok with g++ and msvc locally
 
@LewsTherin consider this: ideone.com/H5tBe
 
Yeah. I guess I shouldn't report the bug to meta because this is the first time it happened.
 
10:57 PM
Why not <cstddef>? You're using namespace std; anyway...
 
Any ideas about my access violation?
 
omg that looks confusing
a few mins thanks
0
A: Java - printing a char a certain amount of times

Lews TherinWhy use a double instead of int? it would lack precision. I assume you mean double[] s = new double[3] s[0]=4; s[1] = 10; s[2] =3 ; for (int i =0; i < s.length; i++) { for(int j=0;j<s[i];j++) { System.out.print("*") ; } System.out.println() ; }

 
Should be - ComPtr<IDXGISwapChain1> m_swapChain;
ComPtr<ID3D11Device1> m_d3dDevice;
ComPtr<ID3D11DeviceContext1> m_d3dDeviceContext;
ComPtr<ID3D11RenderTargetView> m_renderTargetView;
HTML didn't like it though
 
you can put those things in the code block
 
@IDWMaster btw, I think the C# flavour used for WinRT is not the regular flavour. That could explain the performance improvement.
 
11:00 PM
they show up as they should do
 
@RMartinhoFernandes how can that even compile?
 
@RMartinhoFernandes Any way to avoid marshaling in C# to improve performance?
 
@RMartinhoFernandes just good habit
 
In normal apps
 
oh i think i see
 
11:02 PM
@IDWMaster There will always be marshalling. You can control it to some extent, but the easiest route to minimize the overhead probably involves changing the native interface.
 
@RMartinhoFernandes Which I could do
 
@RMartinhoFernandes what happens really?
 
@RMartinhoFernandes What's the best way to change it to optimize it?
 
@LewsTherin It happens that Bar gets access to Foo before it's initialized.
 
Qux.val() is called which uses Foo.x + 1 and returns Bar.x
 
11:03 PM
Which is bad.
Qux is just the bad guy that sets up the loop.
 
But it is fine since Foo.x is initialized to 0
 
@IDWMaster Well, depends. Basically, you want to avoid the slower kinds of marshalling. How to do that is best decided on a case-by-case basis.
@LewsTherin I'll add some more prints to main to show the problem.
 
have to admit
 
ok thanks
 
@RMartinhoFernandes Which kinds of marshaling are considered slow?
 
11:07 PM
I don't see anything wrong with the code
 
@LewsTherin there: ideone.com/5rZga
Obviously, this is a simple contrived example, but I hope it gets the point across.
@IDWMaster Some involve copies back and forth. Obviously those are bad. I don't know all the details, though. You probably can find nice lists on MSDN.
 
11:23 PM
bloody ashes...bad connection today
em
I still don't see the point
 
You can break the invariants because Bar catches Foo with its pants down, erm, accesses Foo during before initialization is complete.
Breaking invariants is bad because, well, it means bugs.
Wow, downvote fest.
WTF? why didn't that onebox?
Can I do: new alignas(foo) char[n] or something?
 

« first day (352 days earlier)      last day (4599 days later) »