Type: Posts; User: Plasmator
Search took 0.06 seconds.
December 7th, 2009, 02:14 PM
It doesn't matter what your compiler is willing to swallow -- this sort of thing is explicitly forbidden by the standard.
If you're writing portable and well-defined code, you mustn't do this.
December 7th, 2009, 12:46 PM
That's absolutely illegal. You are not permitted to define macros with names identical to language keywords.
assert takes one argument; I think you meant assert((expression) && "string-literal"),...
October 8th, 2009, 12:28 PM
Quite easily generated:
October 8th, 2009, 10:30 AM
Yes, it will.
You clearly don't understand how BOOST_PP_REPEAT works, then.
October 7th, 2009, 10:37 PM
It's trivial to implement, albeit the code can become quite bulky (if done in a reusable manner).
Luckily, most of the legwork has been written for you already (see the Boost.Preprocessor library):...
October 6th, 2009, 04:10 PM
Easier to just use isdigit directly:
bool check_string_numeric(const std::string& str)
return (std::find_if(str.begin(), str.end(), std::not1(std::ptr_fun(::isdigit))) == str.end());
September 23rd, 2009, 12:31 PM
A little easier, IMO:
typedef std::istreambuf_iterator<char> in_t;
std::string buffer((in_t(in)), in_t());
EDIT: It's probably also worthwhile to mention that...
September 17th, 2009, 07:53 PM
In this particular case, all that was required of you was to explicitly return from main when a + b + c == 1000.
If your ultimate goal is to find the triplet that satisfies the condition outlined...
September 8th, 2009, 08:45 PM
See the MSDN entries for srand and rand. Ignore the MS-specific parts (e.g., *_s versions), of course.
I don't know what kind of "tutorial" you're expecting because it doesn't get any simpler than...
September 8th, 2009, 08:28 PM
Why are you looking at srand when your error is related to rand?
Regardless, rand takes no arguments.
You, on the other hand, are trying to pass something to it. That's what's causing your...
September 8th, 2009, 08:01 PM
As usual, your best references are the C (ISO/IEC 9899) and/or C++ (ISO/IEC 14882) standards. Their respective drafts are available online for free.
Your compiler already did...
September 8th, 2009, 07:45 PM
Start by reading the documentation. Trial and error usually doesn't work in programming.
September 8th, 2009, 06:48 PM
Uh, check srand's signature. What you're doing makes no sense. You probably intended to write rand, instead.
September 6th, 2009, 12:45 PM
With respect to exclusively supporting stack-based arrays, sure (untested):
template< typename T, class Container = std::deque<T> > class Matrix
September 4th, 2009, 09:44 AM
Not really, no.
Not even preventative measures (e.g., [static] assertions) were covered. :sick:
September 2nd, 2009, 09:45 AM
That's what std::ptr_fun from the functional header's for.
You should prefer to use standard algorithms wherever possible. All of that crap can be replaced by a one-liner involving std::remove_if and std::isspace:
This isn't the right forum for this sort of question.
Assuming that you're targeting a reasonably modern OS (i.e., Win2k+), take a system snapshot with CreateToolhelp32Snapshot and walk through it...
April 27th, 2009, 12:15 PM
JohnW@Wessex's getting at the same thing.
April 27th, 2009, 11:54 AM
Just like kindergarten arithmetic...
1 / 2 = 0
2 / 2 = 1
3 / 2 = 1
4 / 2 = 2
5 / 2 = 2
6 / 2 = 3
7 / 2 = 3
April 27th, 2009, 11:47 AM
You're missing the ****ing point.
When you pass T by-value, T's copy constructor gets invoked. In your case, over and over and over. In short, impossible. Passing T by (const) reference alleviates...
April 27th, 2009, 11:32 AM
Sigh... Let's try this again.
What gets invoked when you pass by-value?
April 27th, 2009, 11:14 AM
Obviously it's not.
First, you can't pass test by-value in your copy constructor. Think about it, the reason should be quite obvious (HINT: what happens when you pass something by-value?)....
April 27th, 2009, 11:05 AM
That's a good thing.
const-qualification in this context doesn't matter much. The point of the snippet was to demonstrate what happens when you attempt to read/write to something...
April 26th, 2009, 11:59 AM
I suggested upgrading because I was under the impression that shadowx360 confused VC++ 9 with an older version.
In fact, IIRC, this sort of "extension" was removed several years ago in an earlier...
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.