Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


noatom

Member Since 23 Jun 2012
Offline Last Active Jul 30 2015 04:31 PM

Topics I've Started

D language code question

30 July 2015 - 03:57 PM

protected string delegate() getTimePeriod()
{
immutable string[] months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];

string path     = buildPath(this._config.path.officialDirectory, "test");

return delegate()
{
	auto time = Clock.currTime();
	return format("%s/%d/%s/savedData.log", path, time.year, months[time.month - 1], time.day);
};
}

My problem here, is the return type. Its a delegate. However, at the end of the function, I don't really understand what the delegate that is returned, points to.

 

I mean, format returns just a string, not an actual function. So the delegate points to...a string?


D language enum question

18 July 2015 - 01:52 PM

I'm a little confused about some code I saw:

private enum logTypes = [
["red"       , "color"],
["blue"       , "color2"],
];

Does that mean that the underlying type is not int and it is string or...? Can we replicate such code in c++?


C++ template specialization problem

07 July 2015 - 02:32 PM

So, here's my code:

template<typename T, typename D>
void bindNullParameter(T& value, const D& toCall){

}

template<>
void bindNullParameter<std::istringstream, std::function<void(unsigned int, std::istream *)>>(std::istringstream& value, const std::function<void(unsigned int, std::istream *)>& toCall){

}

The problem is, when I try to call the function, in this case, the non specialized one,:

bindNullParameter<unsigned long, std::function<void(unsigned int, uint32_t)>>(command, the_method);

I get an error saying that no instance of that function matches the argument list! What am I doing wrong?


C++ signed char and unsigned char question

06 July 2015 - 11:50 AM

unsigned char foo = 253;
signed char foo2 = static_cast<signed char>(foo);
cout << foo2;
So, a signed char is supposed to store a value between -127 and 127.
 
My unsigned char, has a value of 253, which is then cast to a signed char.
How come, that when the code runs, I still see the correct ASCII symbol, even though I am using a signed char?!

[Washu: DO NOT DELETE POSTS.]

Mysql Connector C++ prepared statement values question

22 June 2015 - 01:25 PM

I just want to know, if a value, like an int for example, is actually converted into a string before being sent as part of the command.

pstmt = con->prepareStatement("INSERT INTO test(id) VALUES (?)");

Usually, the ? is replaced with:

pstmt->setInt(1,155);

What I'm curious about is: could I simply make the command:

pstmt = con->prepareStatement("INSERT INTO test(id) VALUES (155)");

And execute it? Would it be the same as setInt? (basically that would mean that the int value is converted to a string before being set as part of the command)


PARTNERS