« first day (466 days earlier)      last day (4482 days later) » 

12:07 PM
hnng, glfw has no error reporting, why would you build a library with absolutely no error reporting?!
 
@LexiR it has no errors! It's perfect, infallible!
 
Oh, you mean it's supposed to return GL_FALSE when I try to open a window?
 
Xeo
Mawnin
 
Greetings
 
It doesn't even set any of OGL's flags. ;-;
 
12:13 PM
:P
 
Xeo
Damn it, Clang ICEs when I use initializer_lists :(
 
@LexiR Yes, glfwOpenWindow returns GL_TRUE on success, something else on failure. Sadly, I don't think there's any way to learn what the cause of the error was.
 
Hi everyone. Is there a compile-time technique for checking if a type is a given namespace?
I've got a code snippet but I don't know how to upload it to the correct board.
 
You mean something like is_in_namespace<string, std>::value should be true, but is_in_namespace<string, boost>::value should be false?
 
@Martinho I've got sample but I don't want to pollute the chat board with it
 
12:22 PM
Use pastebin.com or something.
 
use codepad.org or ideone.com, and make it compilable
 
here's the snippet: pastebin.com/jpDRFsuq
 
The only way you can get that to work is to create an overload for each type in the namespace you want.
There's no way to test a type's namespace.
Or... Gimme a sec to test something :)
 
Sure :)
 
btw, VC++ has the __if_exists statement
 
12:28 PM
Can you use C++11?
@Abyx Both types exist.
 
I was hoping to do this without naming all the classes in the namespace. I know that the SFINAE can be used to ensure that non-valid types fail. For example: I could try testing a whole bunch of FamilyM::ModelN t = _t's , where _t is the object being tested.
Our dev team is using MS Visual Studio .NET 2008. I'm not sure if its C++11 compliant or if my line manager will take kindly to me using novel extensions to the language.
 
@RMartinhoFernandes I'm going to try stepping through the call in a debugger when I have time. I built glfw with symbols so it should be doable.
 
@Olumide I stumbled over enable_if from the boost libs, which seems to be what you search. It provides templates to define template functions/classes which are only valid for specific input types. Link: boost.org/doc/libs/1_48_0/libs/utility/enable_if.html
 
@John And what would be the proper condition?
 
He probably need to add all classes from the valid namespace to it
 
12:37 PM
@John For ease of maintenance and the large number of classes in a namespace, if possible, I'd like to perform this check without naming all the classes in a namespace.
I'm probably asking for too much :)
 
Xeo
One question.. why do you need this check in the first place?
 
What if I promote the namespaces to classes.
 
Xeo
@Olumide Easily doable
It just becomes a member check then
 
@Xeo then pray tell kind Sire (or Madam)
You mean inner class.
 
Xeo
60
Q: Is it possible to write a C++ template to check for a function's existence?

andyIs it possible to write a C++ template that changes behavior depending on if a certain member function is defined on a class? Here's a simple example of what I would want to write: template<class T> std::string optionalToString(T* obj) { if (FUNCTION_EXISTS(T->toString)) re...

This is applicable to any member, really
Still, answer my question please
Why do you need this?
 
12:44 PM
@Xeo: classes in a namespace represent devices from different manufacturers that behave alike, yet they are different.
 
You could just use ADL.
Place the function in the target namespace, and then call it without qualification.
 
Argument dependent lookup? I've only just read about that.
I know that the parent namespace of the argument will searched, and I've tried it but I don't know how to make it work.
 
I suppose this question isn't too silly stupid after all. I hate losing precious SO points.
@RMartinhoFernandes -- thanks! (how did you get so good? :) ) What I'd really like to do next is to use this to instantiate a methods of another a class template that is specialized for a certain namespace.
 
meh currying
I'm confused
anyone want to go discuss this with me in Haskell room?
 
12:53 PM
@TonyTheLion I'm there.
 
me too
 
@TonyTheLion ¬_¬ you sort of make me regret going on reddit in the morning :P
 
Out of context comment of the day: "(are all your balls of the same size and all looking exactly the same? I doubt it)"
 
@TonyTheLion you mean, here right :P
 
@thecoshman why?
 
1:06 PM
@TonyTheLion 'cause I saw this this morning :P reposts suck man :D
 
oh stop whining about reposts
 
@TonyTheLion but they suck ass man
 
Everything that isn't your original is a repost.
 
it's fairly hard these days to find something original
unless you take a picture yourself or make something yourself, and even then, someone might already have made something similar
 
but at least your photo of it is original
 
1:09 PM
true
 
what's really annoying is when you see the same thing reposted in rapid succession
 
well yea, but what can you do about it?
reddit allows reposts
 
and I feel sorry for the guys who post something, then not long after some one else reposts and ends up getting more karma
 
@TonyTheLion it could do with some sort of filter to try to discourage people from reposting things
A very crude system wouldn't be too hard
 
1:11 PM
prolly
 
is imgur one boxed here?
 
Any kind of image.
As long as you link directly to the image and not to the page with the image, it oneboxes.
 
FYI NSFW
 
My eeeeyeeeeeees.
WTF dude.
 
yup r/wtf :P
 
Xeo
1:14 PM
@thecoshman I'll take a wild guess: horse riding?
 
I've not seen it, I just know that I want to know what it is; damn curiosity
 
@RMartinhoFernandes : I've changed void f(T& t) in your example to bool is_in_Family1(T& _t){return true}. I would like to use this (with SFINAE) in order to specialize methods of a third party class Foo.
 
Need code.
Oh wait, you can't use that function in SFINAE.
 
:(
 
Not unless you make it constexpr but that's a C++11 feature.
No, wait, you can use it.
 
1:17 PM
:) ... I love rollercoasters
 
Damn, this is not a good day.
 
@thecoshman ok, why didn't I took that advice seriously?
 
@John so erm... what is it a picture of?
 
@thecoshman Stop talking about it!
 
OOOOH GOD I JUST LOOKED AT IT!!!
 
1:18 PM
I defies any description
 
There is no picture, ok?
 
@John challenge accepted
 
Pardon but I am still new to templates. (Still on page 131 of C++ Templates by Vandevoorde and Josuttis)
 
Stop talking about nonexistent things.
 
@RMartinhoFernandes well then, that's one way to deal with it
I get the feeling a full and frank description would not be appreciated
 
1:20 PM
Luckily there's Eye and Mind Bleach
 
@Olumide Basically, I'm taking advantage of ADL to pick one of the two types_in_this_namespace_are_cool functions.
Then sizeof(types_in_this_namespace_are_cool<T>(create())) will be either sizeof(yes) or sizeof(no), depending on which one gets picked.
 
Xeo
@RMartinhoFernandes Still, you'll get a hard error if you try is_cool<nsX::non_existant>
 
Now you have a boolean trait that you can use for SFINAE with enable_if, for example.
@Xeo That's supposed to give a hard error no?
 
@RMartinhoFernande: your example is binary. Is it okay for each namespace to have its own is_in_FamilyX() function return true. So that the specialization of a third party class Foo e.g. Foo::Bar() is instantiates only if the type is in a certain namespace.
(Traits are still on page 245 of the book. I'll get there someday. I plan to read the entire book, at least twice.)
 
I really want to get me a router that I can play with DD-WRT
sigh, to many things to spend money on :(
 
1:28 PM
@RMartinhoFernandes I'm taking a closer look at your code. I hope you don't mind that I make so many unbaked comments. I'm a total newbie in the templates game.
 
@Olumide Don't worry, I've been warming him up with type traits questions all week :)
I think he just reached cruise velocity
 
1:44 PM
0
Q: What exactly is modular coding, and am I doing it right?

natliI'm trying to figure out if I understand correctly what modular code really is. I know that it's extremely powerful / useful so I want to make sure I'm learning it correctly. To start learning, I made a fairly simple system that groups Entities together based on some criteria. First come, first ...

is this question not somewhat subjective?
modular coding means one thing to one programmer and something slightly different to another
 
Xeo
Ouch, Blah* = new Blah(...); in main...
 
I know
what's wrong here?
 
user142019
The code.
 
user406009
Since when is a number a type?
 
user406009
Well a distinct integer a type.
 
user142019
1:58 PM
The understandable versions of the error messages:
 
user142019
a.cpp:9:23: error: expected a qualified name after 'typename'
    return A<typename X>::call<int>();
                      ^
a.cpp:9:23: error: unknown type name 'X'
a.cpp:15:5: error: template argument for non-type template parameter must be an
      expression
  B<int> b;
    ^~~
a.cpp:7:14: note: template parameter is declared here
template<int X> struct B : A<X> {
             ^
 
user142019
I guess that first you say X is an int, then you say it's a typename.
 
ok, I've got this ideone.com/3LefF
 
fuck
our login/authentication code has gone from ridiculously complex but mostly working, to ridiculously complex and not working unless you apply a ridiculously complex workaround
 
user406009
template<int X> struct A {
template<class Ret> static Ret call() {
return 0;
}
};

template<int X> struct B{
int f() {
return A<X>:: template call<int>();
}
};

int main()
{
B<5> b;
b.f();
return 0;
}
 
2:05 PM
and guess whose responsibility the login component is
 
user406009
Clang told me that you need a template keyword in line 9.
 
user406009
It also told me that you were giving a type to the B template.
 
user142019
Really, C++ makes no sense at all.
 
user406009
Clang helps a lot though.
 
user406009
I just wish C++ could use a different symbol for templates. This whole stupid "Well it can't parse it like that because it might be a < or > or >> operator" is stupid
 
user142019
2:08 PM
@EthanSteinberg yeah they should have used ≤ and ≥.
 
user406009
Still better than Java though.
 
user142019
Is there something like Ideone that uses clang instead of GCC?
 
@WTP that would be nice
 
user406009
I think the main problem with running clang is that you would have to set a lot of settings so as to stop people from hacking your site.
 
user142019
@EthanSteinberg run it in a VM.
 
2:12 PM
@WTP there's the Clang demo page, but you can't use libc++ nor -std=c++11
And it won't run the code
 
@WTP because all our keyboards have those characters ¬_¬
 
user406009
Well there are tons of other keys the standard could have used: "@, `,|,?" are the ones that first spring to mind.
 
@rubenvb So it looks like a duck, but it doesn't quack and it walks like a rock? Mmmm.
2
 
user406009
template@ typename b@ class foo{};
 
user406009
Or template | typename |
class foo
{};
 
user406009
2:17 PM
Imagine the possibilities.
 
user142019
array|vector|vector|map|X, X|||, 1|2|3|4|5|
 
user142019
Unreadable as hell.
 
@EthanSteinberg No. That can't work.
 
user142019
I think there's nothing wrong with < and >. Because of three things: 1) They are readable; 2) C++11 allows >> and 3) How often do you use the >> operator in template parameters?
 
You need an "open" and a "close".
 
2:29 PM
@sehe that's about it, unfortunately. Fortunately, I have a working Clang+libstdc++ (GCC 4.6) on my Windows box :)
 
user142019
Today I figured out that I could write a macro that expands nl to '\n'. This will save me loads and loads of time.
 
@WTP Why would you do that? Macro's are evil! Evil I tell you!!
 
user142019
@rubenvb no, an editor macro
 
user142019
for my text editor
 
user142019
Or tab-expansion, however you want to call it.
 
user142019
2:30 PM
Shortcut.
 
come to think of it, #define nl is quite evil anyways.
 
user142019
Typing '\n' is very tricky on my keyboard.
 
user142019
Since ' is next to \\ and next to return I can only use my right hand to type '\n'. Having my right hand to type nl and my left hand to hit tab is much easier.
 
Markdown wins again?
 
user142019
xD
 
user142019
2:33 PM
WTF!!!11
 
Look, I can type a \ in code markup just fine.
 
user784668
@EthanSteinberg !( and )?
 
user784668
template !(typename T) class Foo {}; Foo!(int) x;
 
@WTP That's not ambiguous.
! as a unary operator is clearly not a template.
 
user784668
D in fact uses !( and ) for that purpose: class Foo(T) {} Foo!(int) x;
 
2:39 PM
I like the use tilde, because it looks and sounds like a wave, as in wave good buy to this object
 
user784668
array!(vector!(map!(string, string)), 5) Doesn't look bad to me.
 
user406009
Isn't the ~ a bitwise not operation?
 
I was going to say that ! is... but now I am not too sure
& ^ and | I know for sure
 
user784668
There's no binary ! nor binary ~. They're unary.
 
user406009
<< = mulptiply by 2 and >> = divide by two?
 
user784668
2:43 PM
@EthanSteinberg Nope.
 
user784668
@EthanSteinberg Multiply by 2 is * 2 and divide by 2 is / 2. Bitshifts are different beasts.
 
user406009
Well I know they are bit shifts, but I am asking about the result on the number.
 
Hi guys
 
user784668
A bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits. It is a fast, primitive action directly supported by the processor, and is used to manipulate values for comparisons and calculations. On simple low-cost processors, typically, bitwise operations are substantially faster than division, several times faster than multiplication, and sometimes significantly faster than addition. While modern high-performance processors usually perform addition and multiplication as fast as bitwise operations, the latter may still be optimal for ...
 
Could someone look in to this ideone.com/ucJp3 ( virtual handling snippet ) and say what I am doing wrong ?
 
user406009
2:45 PM
Casting has no effect on virtual functions.
 
@Fanael yes, they are literally a bit shit, but when dealing with bianry numbers, it results in a multiply or divide by two
 
user406009
You only need dynamic class to "open the interface", ie to access more functions.
 
user406009
If you want to call a base function, you can statically prefex the name. Wait a sec.
 
@thecoshman Except when they don't!
 
@RMartinhoFernandes true enough
 
user406009
2:46 PM
 
user784668
@thecoshman Nope. First, there's a difference between "two" and "a power of two". Two, there are some issues with signedness with shifts.
 
user406009
Well it terns out with a little testing I was right. Bytes in C++ are "big endian".
 
@Fanael yeah, I forgot to clarify the unsigned only factor :P
 
@EthanSteinberg Thanks I knew it. But what is wrong with my dynamic_cast operator ?
 
user406009
I just said, casting the pointer has no effect on virtual functions. Your cast worked perfectly otherwise. Let's change the virtual to a static function and see it work.
 
user406009
 
user406009
Works perfectly.
 
I don't think C++ says anything about order of bits.
 
user406009
No, but when you manipulate bits with the bitwise operators they are "big endian".
 
The shift operators are defined in terms of multiplication and division by powers of two with caveats.
 
Endianness is really about byte order, not bit order.
 
2:49 PM
@EthanSteinberg Learnt something new today. Thanks :)
 
I don't think there's an architecture with bit as an addressable unit.
 
user406009
Oops thought I typed quotes around big endian. I had meant that it is almost like they are big endian.
 
I wonder if anybody wrote a utility which you can feed in a macro and how it's called and then check the result.
 
user406009
You can tell your compiler to give you the preprocessed code.
 
gcc has an option to output the source with expanded macros I know, but I am a bit too lazy to do this :P
 
2:51 PM
$ g++ -E.
 
well let's make one
 
user784668
Or use Eclipse, it knows how to expand macros.
 
@Nils Yes, it's called preprocessor.
 
Or invoke cpp directly.
 
ah yeahs it does
but xCode not :(
 
2:52 PM
Because XCode is crap.
Or however is that capitalised.
 
user142019
@CatPlusPlus Xcode
 
Yeah, whatever.
 
user406009
C++ needs better IDE's.
 
@EthanSteinberg Qt Creator!
 
C++ needs better compilers, first.
 
user784668
2:53 PM
@EthanSteinberg Notepad!
 
And build systems.
Who cares about IDEs.
 
@CatPlusPlus Clang in about a year!
 
user406009
We already have clang. I think that's about as good as its going to get.
 
user142019
And syntax.
 
#define colorProp(name) @property (nonatomic, readonly) CGColorRef #name;

colorProp(blue)

turns into

@property (nonatomic, readonly) CGColorRef "blue";
How can I get rid of the " "?
 
2:54 PM
@EthanSteinberg It will get better, when it can compile lambdas and list-initializers, and constexpr.
 
user142019
remove the #.
 
Don't use stringisation operator?
 
ah that's it
 
## is token paste.
 
2:55 PM
lol too simple
 
user142019
## is concat, you don't want that
 
thx
C++ needs better coders
 
Well, I fail at Objective-C syntax.
 
It's all C preprocessor things.
 
But how would I know what the macro was supposed to produce?
 
2:56 PM
> How can I get rid of the " "?
 
user142019
@RMartinhoFernandes learn about Objective-C properties and Core Graphics.
 
user406009
C preprocessor sucks. I just can't wait till we get modules and we can finally deprecate the junk.
 
Sigh ... one day I will understand templates. For now I've got no choice but to stick with OOP and lots of if statements and virtual functions :(

Bye everyone, and thanks.
 
@WTP What for?
 
user142019
> But how would I know what the macro was supposed to produce?
 
2:57 PM
It's more of C++ compilation model sucking, not preprocessor per se.
 
@WTP I don't mind not being able to help people writing Objective-C.
 
gooood mawning everybody
 
user406009
I want clang to give use JIT bytecode. That would be really cool.
 
Headers are just by-product of that.
 
user142019
Good afternoon.
 
@Nils I doubt he does.
 
user142019
I have seen properties in C++ using macros, like #define GETTER(var) get_ ## var () { return var; } or similar.
 
user406009
What features does Objective-C have over C++ anyways?
 
Dynamic shizinits.
 
reflection
 

« first day (466 days earlier)      last day (4482 days later) »