Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 15094

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. This tag should be used for any question which requires knowledge or expertise with the C++ programming language. This is a general tag which is used for any of the C++ language standards (C++98, C++11, C++17, etc.). The question should identify the compiler being used, the operating system, and which of the C++ standards is being targeted.

13 votes
Accepted

Disk Scheduling Algorithm

You are using C++, but overall, your code looks like C. There are numerous ways to improve your code readability by replacing C standard features by C++ ones. I will give some examples. using namespa …
Morwenn's user avatar
  • 20k
5 votes

Adding two numbers as strings from a textfile

Some basic C++ advice: Don't use using namespace std;. It leads to namespace pollution: it you use another library, you may import names in the global namespace that may clash with those in the std …
Morwenn's user avatar
  • 20k
5 votes
Accepted

Entity management design & smart pointers

The fact that AddEntity leaves behind a unique_ptr to a possibly destroyed entity bothers me (right now, moving your entity does not "destroy" it, but you might add destructible components later). In …
Morwenn's user avatar
  • 20k
7 votes

Given n numbers, find out the least k numbers from them

There are several things that you could improve, especially with regards to containers usage: If you can use C++11 or a more recent version of the C++ standard, then you can use an initializer list …
Morwenn's user avatar
  • 20k
12 votes
2 answers
4k views

Generic absolute value function

I wanted to write a generic abs function that would correctly work for every type. Basically, I wanted to use the following algorithm: If the type is a built-in integer, use std::abs from <cstdlib>. …
Morwenn's user avatar
  • 20k
10 votes

Making C++11 range-based for loops a bit more useful

You can use braces to return from your functions. That way, you won't have to repeat long and cumbersome types (DRY, as much as possible). For example, ConditionalRange::end: iterator_type end() cons …
Morwenn's user avatar
  • 20k
4 votes

Gyrometer/accelerometer sensor fusion with sigmoid transfer function

In addition to what Jerry Coffin said, I would suggest renaming active_float and anneal_float to active and anneal. Since you are using C++, you don't need to have different names for the same functio …
Morwenn's user avatar
  • 20k
8 votes
Accepted

static_new and static_delete

I still have trouble understanding how the whole works, but there are still some small things that could be improved: In your comments, you say that A is an integer type used as a bitmask. The safes …
Morwenn's user avatar
  • 20k
4 votes

Lexer code in C++

Some things you can improve: The initialization of reserved_words is far too complex. You can use an initializer it to simplify it: static const std::unordered_map<std::wstring, LexedFile::Token> r …
Morwenn's user avatar
  • 20k
5 votes
Accepted

AnySetValue - a set of with multiple types of values

I don't see any real problem, only tidbits and things that could potentially be done differently: Your header guard name is actually reserved to the implementation since it uses a double underscore. …
Morwenn's user avatar
  • 20k
6 votes

Decoding and Encoding packet layers using decorator pattern

I don't know about the decorator pattern, but there are things you can improve anyway: Identifiers that begin with an underscore followed by a capital letter are reserved identifiers in C++. Therefo …
Morwenn's user avatar
  • 20k
7 votes

Google Code Jam - T9 Spelling with C++

To complete what has already been said: You are not in C90, not only can you declare variables in a for, but you don't have to declare all your variables at the beginning of a block. Generally speak …
Morwenn's user avatar
  • 20k
4 votes

Messy handler for multiple touch events in a game

There are two things that strike me, just looking at your code: Some lines seem to be overly long. It seems to be at least partly due to the long names of the cocos2d-x API though. You could at leas …
Morwenn's user avatar
  • 20k
11 votes
Accepted

Improved indices trick

You can get rid of the <type_traits> header by replacing your std::enable_if by a bool template specialization: template <::std::size_t, ::std::size_t, bool> struct expand_indices_impl; template <:: …
Morwenn's user avatar
  • 20k
12 votes

One-to-many multiplicity pattern

There are way too many const in your code. const-correctness is great, but you are overdoing it. A few tips to improve your code: When I run g++ with the option -Wextra, I get a warning with this pi …
Morwenn's user avatar
  • 20k

1
2 3 4 5
14
15 30 50 per page