• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 17:55
CEST 23:55
KST 06:55
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S Season 1 - RO8 Preview3[ASL21] Ro8 Preview Pt2: Progenitors8Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10
Community News
Maestros of The Game 2 announcement and schedule !4Weekly Cups (April 27-May 4): Clem takes triple0RSL Revival: Season 5 - Qualifiers and Main Event12Code S Season 1 (2026) - RO12 Results12026 GSL Season 1 Qualifiers25
StarCraft 2
General
Code S Season 1 - RO8 Preview Behind the Blue - Team Liquid History Book Weekly Cups (April 27-May 4): Clem takes triple Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Code S Season 1 (2026) - RO12 Results
Tourneys
Maestros of The Game 2 announcement and schedule ! GSL Code S Season 1 (2026) Sea Duckling Open (Global, Bronze-Diamond) RSL Revival: Season 5 - Qualifiers and Main Event Sparkling Tuna Cup - Weekly Open Tournament
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players
External Content
Mutation # 524 Death and Taxes The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base
Brood War
General
Do we have a pimpest plays list? BGH Auto Balance -> http://bghmmr.eu/ (Spoiler) Asl ro8 D winner interview BW General Discussion AI Question
Tourneys
[ASL21] Ro8 Day 4 Small VOD Thread 2.0 [BSL22] RO16 Group Stage - 02 - 10 May [ASL21] Ro8 Day 3
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Nintendo Switch Thread OutLive 25 (RTS Game) Daigo vs Menard Best of 10
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread The Letting Off Steam Thread Russo-Ukrainian War Thread 3D technology/software discussion
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
How EEG Data Can Predict Gam…
TrAiDoS
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2189 users

The Big Programming Thread - Page 780

Forum Index > General Forum
Post a Reply
Prev 1 778 779 780 781 782 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
October 14 2016 20:23 GMT
#15581
Not sure about C++ but can't you just free the entire vector at once and not bother with freeing every single element in it beforehand?
Time is precious. Waste it wisely.
JWD[9]
Profile Blog Joined November 2015
364 Posts
Last Edited: 2016-10-14 21:56:54
October 14 2016 20:31 GMT
#15582
On October 15 2016 05:23 Manit0u wrote:
Not sure about C++ but can't you just free the entire vector at once and not bother with freeing every single element in it beforehand?


That sounds like the question I wanted to ask. What makes sure, that when an object of this containertype goes out of scope, that all the destructors for the elements it manages get called? And do I have to call them explicitly, especially for nontrivial types? And if not, why was alloc.destroy then used in the reserve function?

edit:
http://stackoverflow.com/questions/18077898/destroy-vs-deallocate

I am even unsure if this answers my question. Because most of the code in the book is wrong in a funny way, so you have to think about it. But allocaters don't really get introduced:
“Messing with allocators” is pretty advanced stuff, and tricky. Leave it alone until you are ready to become an expert.

And then the books ask questions about them, and to then have the outlined solutions be wrong, seems cruel for a book aimed at beginners. ¯\_(ツ)_/¯
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-10-14 20:52:33
October 14 2016 20:42 GMT
#15583
--- Nuked ---
JWD[9]
Profile Blog Joined November 2015
364 Posts
October 14 2016 20:57 GMT
#15584
http://stackoverflow.com/questions/12068950/c-destructors-with-vectors-pointers

It seems like this decision for what to do with vector object only is in the hands of the user if you give pointers as elements, the standard vector should actually call the destructors?

I really just wanna take your word for it Nesserev, and it seems like a plausible way of defining how a vector should behave. Does it come to down to that? Choice of the implementer?
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
October 14 2016 21:05 GMT
#15585
--- Nuked ---
JWD[9]
Profile Blog Joined November 2015
364 Posts
October 14 2016 21:21 GMT
#15586
On October 15 2016 06:05 Nesserev wrote:
Show nested quote +
On October 15 2016 05:57 JWD[9] wrote:
http://stackoverflow.com/questions/12068950/c-destructors-with-vectors-pointers

It seems like this decision for what to do with vector object only is in the hands of the user if you give pointers as elements, the standard vector should actually call the destructors?

I really just wanna take your word for it Nesserev, and it seems like a plausible way of defining how a vector should behave. Does it come to down to that? Choice of the implementer?

Actually, no, you're right. The same for loop should be present in the destructor, but you say that it's not?


It is not. Stroustrup is evil ... or I should acquire the most recent edition of the book.
Nesserev, Manit0u, thanks for being there.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2016-10-14 22:45:24
October 14 2016 22:44 GMT
#15587
--- Nuked ---
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
October 15 2016 06:22 GMT
#15588
[image loading]

Brilliant!
Time is precious. Waste it wisely.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2016-10-15 08:09:13
October 15 2016 07:38 GMT
#15589
Guys I feel really stupid but how does the coin change problem work? I've been thinking about it the last 3 hours and I think my brain is fried... I don't understand how you get to breaking it into solutions not containing coin X and solutions containing coin X.

Also follow-up, what happens if you introduce same value denominations? Like your set of coins is {1a, 1b, 5, 10}.

Also does the solution vary for permutations of coins? Ugh my head.
There is no one like you in the universe.
Acrofales
Profile Joined August 2010
Spain18287 Posts
October 15 2016 08:29 GMT
#15590
On October 15 2016 15:22 Manit0u wrote:
[image loading]

Brilliant!

Yes, but it wouldn't work on me.

Heh, guess I'm not a moron. Or perhaps a really obstinate moron
Acrofales
Profile Joined August 2010
Spain18287 Posts
October 15 2016 08:32 GMT
#15591
On October 15 2016 16:38 Blisse wrote:
Guys I feel really stupid but how does the coin change problem work? I've been thinking about it the last 3 hours and I think my brain is fried... I don't understand how you get to breaking it into solutions not containing coin X and solutions containing coin X.

Also follow-up, what happens if you introduce same value denominations? Like your set of coins is {1a, 1b, 5, 10}.

Also does the solution vary for permutations of coins? Ugh my head.


Too lazy to google. What is the coin change problem? Is it simply the question of what change to give to a customer to minimize number of coins? If so, I don't get the problem you're having.

Or are you working on some variation where you want all permutations?
Khalum
Profile Joined September 2010
Austria831 Posts
Last Edited: 2016-10-15 09:08:38
October 15 2016 09:08 GMT
#15592
On October 15 2016 05:10 JWD[9] wrote:
[..]

[..]
vector_base(const A& a, long unsigned int n)
:alloc{a}, sz{n}, elem{alloc.allocate(n)}, space{n} {}
[..]

[..]


Are the brackets for the initialization list actually written like this in the book?
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
Last Edited: 2016-10-15 16:57:08
October 15 2016 16:50 GMT
#15593
Heh, every day you learn something new. Today I've learned a cool way of checking if a number is a power of 2:


n > 0 && (n & (n - 1)) == 0;


I really need to utilize bitwise operations more.
Time is precious. Waste it wisely.
Mr. Wiggles
Profile Blog Joined August 2010
Canada5894 Posts
October 15 2016 17:27 GMT
#15594
On October 16 2016 01:50 Manit0u wrote:
Heh, every day you learn something new. Today I've learned a cool way of checking if a number is a power of 2:


n > 0 && (n & (n - 1)) == 0;


I really need to utilize bitwise operations more.

If you're interested in bit-level manipulations and micro-optimisations, check out Hacker's Delight.

http://www.hackersdelight.org
you gotta dance
Acrofales
Profile Joined August 2010
Spain18287 Posts
October 15 2016 17:28 GMT
#15595
On October 16 2016 01:50 Manit0u wrote:
Heh, every day you learn something new. Today I've learned a cool way of checking if a number is a power of 2:


n > 0 && (n & (n - 1)) == 0;


I really need to utilize bitwise operations more.

Heh. Hadn't thought of that, but it's pretty nifty!
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
October 15 2016 17:44 GMT
#15596
On October 16 2016 02:27 Mr. Wiggles wrote:
Show nested quote +
On October 16 2016 01:50 Manit0u wrote:
Heh, every day you learn something new. Today I've learned a cool way of checking if a number is a power of 2:


n > 0 && (n & (n - 1)) == 0;


I really need to utilize bitwise operations more.

If you're interested in bit-level manipulations and micro-optimisations, check out Hacker's Delight.

http://www.hackersdelight.org


Thanks. I'll be sure to check it out seeing how most of my career for the past 2 years has been code optimization and refactoring.

I also need to re-learn some maths since I suck at it now (that's what you get when you decide to pursue a programming career after nothing but humanities in education).
Time is precious. Waste it wisely.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
October 15 2016 19:29 GMT
#15597
On October 15 2016 17:32 Acrofales wrote:
Show nested quote +
On October 15 2016 16:38 Blisse wrote:
Guys I feel really stupid but how does the coin change problem work? I've been thinking about it the last 3 hours and I think my brain is fried... I don't understand how you get to breaking it into solutions not containing coin X and solutions containing coin X.

Also follow-up, what happens if you introduce same value denominations? Like your set of coins is {1a, 1b, 5, 10}.

Also does the solution vary for permutations of coins? Ugh my head.


Too lazy to google. What is the coin change problem? Is it simply the question of what change to give to a customer to minimize number of coins? If so, I don't get the problem you're having.

Or are you working on some variation where you want all permutations?


It's the one where given a set of coins and a target value, given an infinite amount of each coin how many ways can you use the coins to reach the target value. It's the dynamic programming problem. I don't understand the logic of it.
There is no one like you in the universe.
JWD[9]
Profile Blog Joined November 2015
364 Posts
October 16 2016 00:53 GMT
#15598
On October 15 2016 18:08 Khalum wrote:
Show nested quote +
On October 15 2016 05:10 JWD[9] wrote:
[..]

[..]
vector_base(const A& a, long unsigned int n)
:alloc{a}, sz{n}, elem{alloc.allocate(n)}, space{n} {}
[..]

[..]


Are the brackets for the initialization list actually written like this in the book?

Yes

On October 15 2016 07:44 Nesserev wrote:
Kk, so I got my paws on Stroustrup's book, and read the section. I guess I didn't look at your code well enough.
There are two classes:
- vector_base: used as a base class for vector<T,A>; manages the allocated memory of a vector
- myvector<T,A>: used to store objects

The class vector_base is only aware of the big block of memory allocated for the vector, and is not aware of the objects stored in said block of memory. The destructor in your code, was the destructor for vector_base, which only handles cleaning up the vector's reserved memory.

The destructor of myvector<T,A> is not shown, but it would contain the for loop to clean up the elements.
The reserve() method was also for myvector<T,A>, and has the for loop for the reason I posted earlier.


Also, isn't the second edition of 'Programming: Principles and Practice Using C++' the latest one?

I checked, seems it is the latest version.
Awww, I constructed and destructed the elements in the vector_base. I can see why I should not do that. Now it also makes sense why he used uninitialized_copy in the reserve function and could not rely on the vector_base destructor.
At least I was right for feeling stupid
I thank you Nesserev!
RoomOfMush
Profile Joined March 2015
1296 Posts
October 16 2016 14:16 GMT
#15599
I would like to write a user manual to a piece of software but I am not quite sure what kind of software / framework I am going to use. I would like to get some recommendations if possible.

What I need is something like a small wiki. Platform independent, with hyperlinks to important topics, a table of content, search function would be nice; all the standard quality-of-life features we have nowadays.
I would also like to generate this manual automatically; ideally programmatically. I would also like to open this user manual from inside the java application.

I was thinking an HTML solution would be great for that. I could have the application start a browser and display the manual. Does anybody know of some tool / framework / toolkit / software / etc that can help me?
Manit0u
Profile Blog Joined August 2004
Poland17743 Posts
October 16 2016 14:30 GMT
#15600
It seems that what you need could easily be done with just a bit of html and js. Alternatively, there should be software that converts *doc comments to an html file serving as your documentation. I'm sure it's true for PHPDoc and RDoc comments so it should be available for Java and other languages.
Time is precious. Waste it wisely.
Prev 1 778 779 780 781 782 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 2h 6m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Hui .124
JuggernautJason103
CosmosSc2 22
StarCraft: Brood War
Dewaltoss 71
NaDa 15
Artosis 1
League of Legends
Doublelift3002
Reynor76
Counter-Strike
fl0m1670
Super Smash Bros
PPMD65
Other Games
tarik_tv4937
Grubby3124
Liquid`RaSZi1786
FrodaN693
shahzam512
monkeys_forever215
syndereN212
Liquid`Hasu137
ArmadaUGS106
Mew2King62
ViBE40
summit1g0
Organizations
Other Games
gamesdonequick2056
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 16 non-featured ]
StarCraft 2
• musti20045 24
• Adnapsc2 16
• Reevou 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• imaqtpie2224
Other Games
• Scarra874
• Shiphtur385
Upcoming Events
Replay Cast
2h 6m
Escore
12h 6m
The PondCast
12h 6m
WardiTV Invitational
13h 6m
Zoun vs Ryung
Lambo vs ShoWTimE
Big Brain Bouts
18h 6m
Fjant vs Bly
Serral vs Shameless
OSC
1d
Replay Cast
1d 2h
CranKy Ducklings
1d 12h
RSL Revival
1d 12h
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
1d 13h
Krystianer vs TriGGeR
Cure vs Rogue
[ Show More ]
uThermal 2v2 Circuit
1d 17h
BSL
1d 21h
Artosis vs TerrOr
spx vs StRyKeR
Replay Cast
2 days
Sparkling Tuna Cup
2 days
RSL Revival
2 days
Cure vs Zoun
Clem vs Lambo
WardiTV Invitational
2 days
BSL
2 days
Dewalt vs DragOn
Aether vs Jimin
GSL
3 days
Afreeca Starleague
3 days
Soma vs Leta
Wardi Open
3 days
Monday Night Weeklies
3 days
OSC
4 days
CranKy Ducklings
4 days
Afreeca Starleague
4 days
Light vs Flash
Replay Cast
5 days
Replay Cast
6 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2026-05-05
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
Acropolis #4
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

Escore Tournament S2: W6
KK 2v2 League Season 1
BSL 22 Non-Korean Championship
YSL S3
Escore Tournament S2: W7
Escore Tournament S2: W8
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.