• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 16:43
CET 21:43
KST 05:43
  • 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
Team Liquid Map Contest #22 - Presented by Monster Energy5ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13
Community News
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool30Weekly Cups (March 9-15): herO, Clem, ByuN win42026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains18
StarCraft 2
General
Weekly Cups (August 25-31): Clem's Last Straw? Weekly Cups (March 9-15): herO, Clem, ByuN win Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Team Liquid Map Contest #22 - Presented by Monster Energy Serral: 24’ EWC form was hurt by military service
Tourneys
RSL Season 4 announced for March-April Sparkling Tuna Cup - Weekly Open Tournament WardiTV Team League Season 10 KSL Week 87 [GSL CK] #2: Team Classic vs. Team Solar
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
Buy weed dexies in Australia (WhatsApp 0480852135) BGH Auto Balance -> http://bghmmr.eu/ ASL21 General Discussion Gypsy to Korea JaeDong's form before ASL
Tourneys
[BSL22] Open Qualifiers & Ladder Tours [Megathread] Daily Proleagues Small VOD Thread 2.0 IPSL Spring 2026 is here!
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates
Other Games
General Games
General RTS Discussion Thread Nintendo Switch Thread Path of Exile Stormgate/Frost Giant Megathread Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion 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
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread Russo-Ukrainian War Thread Mexico's Drug War
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Movie Discussion! [Req][Books] Good Fantasy/SciFi books [Manga] One Piece
Sports
Formula 1 Discussion 2024 - 2026 Football Thread Tokyo Olympics 2021 Thread General nutrition recommendations Cricket [SPORT]
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2035 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
Poland17695 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
Poland17695 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
Spain18239 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
Spain18239 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
Poland17695 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
Spain18239 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
Poland17695 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
Poland17695 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
BSL
20:00
S22 - Ladder Tour #2
LiquipediaDiscussion
LAN Event
16:30
StarCraft Madness
Airneanach106
Liquipedia
PSISTORM Gaming Misc
15:55
FSL semifinals: PTB vs ASH
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
elazer 303
JuggernautJason78
Nathanias 75
UpATreeSC 65
CosmosSc2 58
Ketroc 43
Vindicta 39
StarCraft: Brood War
EffOrt 549
Horang2 481
Shuttle 327
ggaemo 154
Dewaltoss 105
hero 93
Free 90
ZZZero.O 77
ivOry 13
SilentControl 10
Dota 2
monkeys_forever316
LuMiX1
Counter-Strike
fl0m5004
shoxiejesuss866
Heroes of the Storm
Liquid`Hasu490
Khaldor422
MindelVK14
Other Games
Grubby3224
FrodaN2241
byalli465
JimRising 464
ToD170
Hui .76
Trikslyr57
ceh941
Organizations
Other Games
gamesdonequick886
Dota 2
PGL Dota 2 - Main Stream121
Other Games
BasetradeTV28
StarCraft 2
angryscii 24
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 22 non-featured ]
StarCraft 2
• printf 30
• Adnapsc2 29
• LUISG 12
• Reevou 6
• Kozan
• LaughNgamezSOOP
• IndyKCrew
• intothetv
• Migwel
• AfreecaTV YouTube
• sooper7s
StarCraft: Brood War
• 80smullet 15
• Azhi_Dahaki10
• Pr0nogo 3
• Michael_bg 2
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota21342
• WagamamaTV857
Other Games
• imaqtpie1070
• Shiphtur235
Upcoming Events
RSL Revival
13h 17m
herO vs MaxPax
Rogue vs TriGGeR
BSL
23h 17m
Replay Cast
1d 3h
Replay Cast
1d 12h
Afreeca Starleague
1d 13h
Sharp vs Scan
Rain vs Mong
Wardi Open
1d 15h
Monday Night Weeklies
1d 20h
Sparkling Tuna Cup
2 days
Afreeca Starleague
2 days
Soulkey vs Ample
JyJ vs sSak
Replay Cast
3 days
[ Show More ]
Afreeca Starleague
3 days
hero vs YSC
Larva vs Shine
Kung Fu Cup
3 days
Replay Cast
4 days
KCM Race Survival
4 days
The PondCast
4 days
WardiTV Team League
4 days
Replay Cast
5 days
WardiTV Team League
5 days
RSL Revival
6 days
Cure vs Zoun
WardiTV Team League
6 days
BSL
6 days
Liquipedia Results

Completed

Proleague 2026-03-20
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
CSL Elite League 2026
RSL Revival: Season 4
Nations Cup 2026
NationLESS Cup
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
CSL 2026 SPRING (S20)
CSL Season 20: Qualifier 1
Acropolis #4
IPSL Spring 2026
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
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.