• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 02:54
CEST 08:54
KST 15:54
  • 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
ByuL, and the Limitations of Standard Play1Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12TL.net Map Contest #22 - Voting & Ladder Map Selection7Code S Season 2 (2026) - RO8 Preview8
Community News
[TLMC] Summer 2026 Ladder Map Rotation05.0.16 patch for SC2 goes live (8 worker start)74ZeroSpace at Steam NextFest - Last free demo31Weekly Cups (June 8-14): Clem and Solar double, PTR tested0RSL: S6 Finals played at BlizzCon 202611
StarCraft 2
General
5.0.16 patch for SC2 goes live (8 worker start) Is the larve respawn broken? The Death of Cheese: From a Professional Cheeser Mizenhauer's Douyu Cup Preview ByuL, and the Limitations of Standard Play
Tourneys
Douyu Cup 2026: $20,000 Legends Event (June 26-28) Maestros of The Game 2 announcement and schedule ! RSL Revival: Season 6 - Qualifiers and Main Event INu's Battles#17 <BO.9> Sparkling Tuna Cup - Weekly Open Tournament
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
The PondCast: SC2 News & Results Mutation # 531 Experimental Artillery Mutation # 530 One For All Mutation # 529 Opportunities Unleashed
Brood War
General
Farewell Beloved Starcraft (Youtube Videos) ASL 22 Proposed Map Pool BW General Discussion vespene.gg — BW replays in browser Quality of life changes in BW that you will like ?
Tourneys
[ASL21] Grand Finals [Megathread] Daily Proleagues The Casual Games of the Week Thread [BSL22] GosuLeague Casts - Tue & Thu 22:00 CEST
Strategy
Simple Questions, Simple Answers Creating a full chart of Zerg builds Relatively freeroll strategies Why doesn't anyone use restoration?
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Beyond All Reason Nintendo Switch Thread ZeroSpace at Steam NextFest - Last free demo
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
The Games Industry And ATVI US Politics Mega-thread Canadian Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread
Fan Clubs
The HerO Fan Club! The herO Fan Club!
Media & Entertainment
Movie Discussion! Series you have seen recently... [Req][Books] Good Fantasy/SciFi books [TV/BOOK] *SPOILERS* Game of Thrones Discussion
Sports
2024 - 2026 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 McBoner: A hockey love story Cricket [SPORT]
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Facing Challenges in Mobile App Development
TL Community
The Automated Ban List
Blogs
Listen To The Coaches!
TrAiDoS
An Exploration of th…
waywardstrategy
I'm an arrogant trash talke…
FlaShFTW
Gauntlet SC2: A Retrospectiv…
Ctone23
ramps on octagon
StaticNine
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8874 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
Poland17774 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
Poland17774 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
Spain18331 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
Spain18331 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
Poland17774 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
Spain18331 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
Poland17774 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
Poland17774 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
Douyu Cup 2020
05:00
2026 - Day 3
Ryung 856
WardiTV688
CranKy Ducklings422
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Ryung 856
WinterStarcraft740
ProTech147
StarCraft: Brood War
Mind 51
ZergMaN 25
Dota 2
NeuroSwarm156
Counter-Strike
Coldzera 812
Super Smash Bros
Mew2King96
Heroes of the Storm
Khaldor133
Other Games
summit1g9740
RuFF_SC267
Livibee44
Organizations
Other Games
gamesdonequick735
BasetradeTV175
StarCraft: Brood War
lovetv 24
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 13 non-featured ]
StarCraft 2
• CranKy Ducklings SOOP14
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1553
• Lourlo1242
Upcoming Events
Maestros of the Game
5h 37m
herO vs Classic
Maru vs Serral
BSL22 NKC (BSL vs China)
7h 7m
Bonyth vs TerrOr
eOnzErG vs Dewalt
XuanXuan vs TBD
Douyu Cup 2020
22h 7m
BSL22 NKC (BSL vs China)
1d 7h
Mihu vs TBD
Online Event
1d 8h
RSL Revival
1d 19h
WardiTV Weekly
2 days
RSL Revival
3 days
RSL Revival
3 days
Bombastic Starleague
3 days
[ Show More ]
Kung Fu Cup
4 days
OSC
4 days
CrankTV Team League
5 days
Bombastic Starleague
5 days
Replay Cast
5 days
The PondCast
6 days
HomeStory Cup
6 days
Replay Cast
6 days
Liquipedia Results

Completed

CSL Season 21: Qualifier 1
WardiTV Spring 2026
Heroes Pulsing #2

Ongoing

IPSL Spring 2026
Acropolis #4
YSL S3
BSL 22 Non-Korean Championship
CSL Season 21: Qualifier 2
SCTL 2026 Spring
Douyu Cup 2026
Maestros of the Game 2
Murky Cup 2026
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
IEM Rio 2026

Upcoming

CSL 2026 Summer (S21)
CSLAN 4
Blizzard Classic Cup 2026
Kung Fu Cup 2026 Grand Finals
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
HSC XXIX
BCC 2026
Light Tournament 2026
Eternal Conflict S2 Finale
Eternal Conflict S2 E1
Heroes Pulsing #3
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 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.