« first day (2558 days earlier)      last day (1405 days later) » 

12:36 AM
@HeebyJeebyMan Would you mind if I added a stack snippet to your "Longest Non-Repeating Substring" challenge? It would display the score of the input submission (and is verbose enough not to encourage copy-pasting/golfing that specific solution)
 
@ConorO'Brien Go ahead
 
12:55 AM
-1
Q: Three students derive

Nadin Kamil(II) Three students derive the following equations in which x refers to distance traveled, v the speed, a the acceleration (m/s2), t the time, and the subscript zero (0) means a quantity at time t = 0: (a) x = vt2 + 2at, (b) x = v0t + \a t2, and (c) x = v0t + 2at2. Which of these could possibly b...

 
@Mego just finished my federal taxes :| have to do state tax now
 
"Good morning, Green orb!" -> "ing, Gre"
how are they the longest required substrings? can somebody explain?
 
1:14 AM
they are the longest substrings such that no character occurs twice in it
 
Why not "morn" ?
oh wait nvm i got it now
 
because "ing, Gre" is longer
 
i thought those were 2 different substrings lol..
 
ohh ok
 
1:49 AM
maximum call stack size exceeded when i try that snippet
 
2:02 AM
Clever title suggestions for this before I post it?
 
Cool story: I was planning on buying a mystery jackpot box off of scam school (magic decks, puzzles ect...) for a solid 30 bucks. They sold out today right as I got my paycheck (was late). I emailed the dude who runs it and said "Hey my paycheck was late and can't buy the 100 dollar one, the 30 dollar one is sold out. Anything you can do?" He emailed me back and said would talk to Dave (the co-host). They made another box for me and set it up so I could buy it. Feelsgoodman
 
@MDXF "Nested runlength encoding"
 
@Laikoni Whoa, is that similar to what RLE does?
 
@MDXF Depends on whether only single character runs are substituted or also runs of the same string.
 
Hmm. I might change the title later once I read up on RLE.
Would the be appropriate for this challenge, then?
 
2:14 AM
Right, it should be "Nested run-length decoding".
The tag is pretty broad and kind of redundant when you mention somewhere "decoding" in the challenge, but yes I think it fits.
 
I think almost all of our tags are like that tbh
Posted, waiting for bot
 
@MDXF Is a[bc]d a valid input?
 
@Laikoni Iff d is a digit. Clarified that
(added You may assume that each closing bracket ] has a digit after it.)
 
Anonymous
@Dennis Could the comments on this answer get cleaned up/moved to chat? There's quite a lot.
 
Without clicking on the link I knew which answer it is... :(
 
2:26 AM
Idk why that answer is such a big deal, we've got more pitiful answers than that that don't have any controversy
 
Done.
Because voters...
(i.e., most of the HNQ voters)
 
Anonymous
I would raise a mod flag, but a) chat.stackexchange.com/transcript/message/42517902#42517902 (and surrounding context), and b) I already have a pending mod flag on it (that's pending due to the controversy regarding "baseline" submissions)
 
@Mego I hoped to reach a consensus before doing that, but that seems to have been overly optimistic.
 
0
Q: Bracket Expansion!

MD XFYour challenge is to expand some brackets in a program's input as shown: Find a string s between an opening bracket [ and a closing bracket ], with a single digit n after the closing bracket. Remove the brackets. Replace s with itself repeated n times. (If n is 0, simply remove s.) Go to step 1...

 
Anonymous
@Dennis Well, the votes on the meta post have more or less settled from what I've seen. I can understand you not wanting to delete comments, since many of them are pertinent to the debate, and the debate is still somewhat fresh, but at least moving them to chat would save precious vertical screen space.
 
2:29 AM
.oO(doesn't just not clicking on the show x more comments button save screen space though?)
 
Anonymous
@MDXF Sure, but a) that button can't be unclicked without reloading the page, and b) excessive conversation in comments isn't allowed network-wide (metas notwithstanding), and moving to chat is the standard fix
 
Yeah I know that, I'm just saying
 
3:01 AM
Considering a run for moderator.
...but I admit that I'm not as confident as I was during the 2016 elections.
 
@HeebyJeebyMan Minimize the length of the longest unique substring.
(was it too late?)
 
wait we have mod election o_O
should i like try (i doubt i will get close but i might as well ¯\_(ツ)_/¯ doesn't cost me anything to just throw out an attempt)
 
I'll run if other people want me to / say that they'll support me.
 
i might run but i feel like almost everyone else who runs will be way better suited than me and running won't really do anything but clutter meta post :p
 
3:32 AM
@user202729 Indeed. (@NewMainPosts)
 
4:17 AM
How should I express pieces.every(piece => pieces.count(piece) == 1) (or pieces == pieces.unique()) in English?
(context: new main post)
(to respond to this comment)
 
no pieces are duplicate?
 
Guess it should be fine. Riker's comment made me confused.
 
0
A: Sandbox for Proposed Challenges

Jo KingRussian Nesting Quine quine code-golf source-layout Write a program or function that, when embedded N times in itself, will print itself embedded N-1 times. For example, the program abcd prints nothing, ababcdcd will print abcd, abababcdcdcd will print ababcdcd, ad infinitum. Rules: Standard...

 
 
1 hour later…
5:51 AM
I just spent a good 25 minutes trying to figure out how to declare a constant in Haskell before remembering I was using Haskell.
 
6:10 AM
is it just me or did github change commit list ui
 
 
2 hours later…
7:46 AM
Wait something is actually happening with PPCG? New mods? Hold me I'm not used to this
 
7:59 AM
@Downgoat I notice no change.
 
8:39 AM
The top voted questions on Meta are in an ironic order
 
9:03 AM
Hi @LeakyNun
 
hi
 
Suppose I wanna write a programme to find v_p([a+b]^p - [a^p+b^p]) for prime p and 0 < a,b < p, where v_p(x) denote the highest exponent of p dividing x. I wrote a code in python, but for primes > 105, it's not working (Showing "OverflowError: integer division result too large for a float"). What to do ?
 
@Downgoat I think every commit was separate before
@AlexKChen use // when you want integer division
normal / introduces floats
 
My code for calculating v_p(x) is this:
 
when you divide always use a double slash that will fix it
 
9:12 AM
Yeah, now it works.
But now it's too slow for primes > 500 :(
How can I speed it up ?
 
show us the code
 
def vp(n):
	i = 0
	while (n % p) == 0:
		i = i + 1
		n = n//p
	return i
def q(a,b,p):
	return vp( (a+b)**p - (a**p + b**p), p)
 
int(n/p) -> n//p
 
def m(p):
	t = 1
	s = []
	for j in range(1, p):
		for i in range(1, p):
			b = q(i,j,p)
			if b > t:
				t = b
				s = [(i, j)]
			elif b == t:
				s.append((i,j))

	return [t,s]
 
also, is this Python 2 or 3
 
9:14 AM
@NieDzejkob Yeah, that's from an older vrsion. Corrected.
@NieDzejkob python 3
 
holy shit this is some IOCCC stuff
 
So basically I wan't to find maximum value of v_p[(a+b)^p-(a^p+b^p)] when p is fixed and 0 <a,b<p and all values for which it's attained.
@NieDzejkob What does that mean ?
 
where is the p passed to vp?
 
Oh sorry that's from an older version of the code
 def vp(n, p):
	i = 0
	while (n % p) == 0:
		i = i + 1
		n = n//p
	return i
OK, so how can I speed it up ?
 
So vp counts how many times n divides p
Run a profiler on it
 
9:17 AM
p divides n
 
and see where the majority of time is spent
@AlexKChen yeah, p divides n, right
 
I guess majority of time is spend on calculating (a+b)^p - (a^p+b^p) when p is large, and a,b are also large.
 
@AlexKChen guess?
seriously, profile it
 
sorry I don't know profiling. I only know basics fo coding.
 
google is your friend
and what is m supposed to achieve?
q calculates what you specified as the problem statement
afaics
@AlexKChen just run python with -m cProfile before the filename of your script
 
9:28 AM
ok
thanks
 
10:05 AM
@AlexKChen use a language that uses arbitrary precision arithmetic?
@AlexKChen International Obfuscated C Code Contest
 
@betseg he uses python...
 
10:21 AM
ooh, my rep is exactly 64000
 
10:45 AM
Not interesting enough until 65536 :p
 
2
Q: Check if all elements in a matrix are connected

Stewie GriffinInput: A matrix containing integers in the range [0 - 9]. Challenge: Determine if all non-zero elements are connected to each other vertically and/or horizontally. Output: A truthy value if all are connected, and a falsy value if there are non-zero elements/groups that aren't connected to ot...

 
Heh, two proposals for OEIS: A(n) is nth positive number which does not occur in any OEIS sequence. And A(n) is the nth (beginning from -1) negative ditto number.
 
@Adám the first sequence is a paradox
 
@NieDzejkob Ah, should be any other than itself, of course.
Actually, they could be combined into A(-n) and A(n).
 
Anonymous
11:03 AM
@AlexKChen That's probably the fastest that it is going to get
 
Anonymous
The only other way I can think of doing it involves exponentiation, which is expensive
 
you could calculate a^p once per a, instead of calculating it for every value of b, but idk
 
Anonymous
I was just looking at the code for computing the multiplicity of p**k | n
 
@NieDzejkob good idea
Although I know nohting about memeory etc, which one would be faster: storing 3p values in a dictionary and retrieving it or calculating a^p each time ?
 
11:30 AM

 V'dibarta Bam

"And speak of them" (Deut. 6:7) Speak of Jewish life and learn...
@Mego Can you move this conversation there?
 
Anonymous
 
Anonymous
6 messages moved to Trash
 
@AlexKChen measure it
 
Anonymous
@AlexKChen Probably the first. Exponentiation is expensive (unless it's 2**n for non-negative integer n)
 
11:47 AM
...another election? how many mods do we even need with declining activity :P
 
Anonymous
12:01 PM
@EriktheOutgolfer More than 1-2 :P
 
currently we have mod activities in decreasing order Dennis>Martin Ender>Doorknob>Alex A.
 
Anonymous
@EriktheOutgolfer That's probably accurate
 
the first two are considerably active
the third is often active too
unfortunately for the fourth job is sucking their activity :(
but all have done considerable action in the past, from when we graduated until 2018-01-29
with site analytics, I've observed that from 2017-09-25, after a spike, activity has been descreasing over time
from then on, we didn't need more mods
result: I predict one or more of the mods will resign...
 
@EriktheOutgolfer Alex really should have resigned months ago
 
you can't really judge like that, you can't see how internal mod stuff is going on...
 
What I can see is weeks long periods of not even logging on, months long periods of not submitting answers/questions.
 
Is there an RSS feed or something for new challenges?
 
uh, yeah?
(go to the bottom of the home page and click on "recent questions feed")
 
12:45 PM
Challenges, not questions.
 
Oh
It isn't there on mobile site :(
 
@EriktheOutgolfer IMO you should remove “You can do X, Y or Z. ” part
 
@user202729 no, it says "questions" there
 
If they are going to be mods, then they should know what they should pick from
 
@EriktheOutgolfer <updated> element there is the last answer/edit right? Is there one that only lists questions' times?
(I'm trying to make IFTTT notify me for a new challenge)
 
12:52 PM
@betseg I presume so
 
1:15 PM
Can anyone explain here that we don't like "do X without Y"? (often it's quite unfortunate that built in get more upvotes)
No doubt it's more challenging to actually solve the problem yourself (be it with the mentioned method or some other method) than by using built-ins to do so. But why not just mention sth. along the lines "You're encouraged to solve this problem by using Y"? Likely there'll be someone posting a built-in solution, but maybe they include a solution using Y - if not, simply don't upvote and problem solved. — BMO 19 hours ago
Oddly Grace Note's example post (Twitter ad) tend to get a lot of upvotes and downvotes...
 
because the twitter account's lame :P
 
Do we have a Twitter account? What is Twitter?
 
click on the ad
 
1:41 PM
Blog post relevant to code-golf: Permuting Internal Letters
 
Can I just say I'm impressed by the many different ways that people have answered Diluted Integer Sums.
 
So basically NewMainPosts + NewMetaPosts + something_else_I_don't_know.
 
This community is full of really smart people.
5
 
I'm not that sure about the ratio...
 
@Adám which golf in that post is yours?
 
1:54 PM
@J.Sallé '\S+'⎕r{{⍵[∪1,{⍵,⍨?⍨⍵-1}≢⍵]}⍵.Match}x
 
Anonymous
@AdmBorkBork :P
 
@J.Sallé Proudly the slowest of them all!
 
@Adám I guessed 'fb' because it's the shortest but I should've figured :p
@Adám efficiency is totally overrated anyway
3
 
Luakit ESC interfere with SE too much...
> This suggestion still needs 1 approve vote from other reviewers. Close this popup (or hit Esc) to continue.
 
@J.Sallé ngn came up with two much shorter functions: {⍵[⍋0+∘?¨⍨+\1,⌈/' '=⊢⌺4⊢⍵]}x and the (in his own words, "unreadable") ⊂⊃¨⍨∘(⍋+\+∘?≠⍨)1,(' '∊⊢)⌺4.
 
2:00 PM
@ManishKundu One of the problems is to ban them you have to (have some one to) learn the language used by answerers and then check...
 
@Adám Why would anyone need to read the code anyway? Just code in a way that it does the job and doesn't create bugs so nobody will need to read your code to fix it.
 
@betseg How will they implement feature creep then?
 
@user202729 okay well I allowed any method already. I hope things are better now
 
@Adám just guess the future and code all the future needs
 
@Adám I like how the first one is basically the whole function inside the square brackets
 
2:03 PM
Fun fact: In Shakespeare Programming Language, goat is considered a negative noun.
 
@betseg We're still working on implementing ⎕ESP.
 
@NieDzejkob As in You should goat do that, it's goat a good idea.?
 
> goat (n.) 2. a lecherous man.
> 3. (informal) a stupid person; a fool.
 
@J.Sallé As in You are a dirty goat., which sets the value of the character being spoken to to -2.
 
@Adám neat, I'm expecting it on the 1st april
 
2:10 PM
I think the challenge is good now. Should I post it?
 
Anonymous
@ManishKundu I would wait. It's only been in its current form for a few minutes.
 
If you ask Mego, probably no.
 
About time! In Dyalog v16.0, "branch" will become sensitive to index origin. See conversion tools at https://github.com/dyalog/iobranch
 
2:30 PM
Anyone know what's the star ordering algorithm of chat?
(side note: Because solving a polynomial is hard, I expect a lot of initial built in solutions and a non builtin posted much later (and hopefully get more upvotes))
(just read the "results are integers" part. There should be a lot of non-builtin)
 
Anonymous
@user202729 From what I've seen, it looks like date of message, total number of stars, and date of last star matter in decreasing order of precedence, with some threshold on closeness for dates
 
Conjecture: Without Python eval, Jelly implementation of (all-connectedness) takes at least n^2 time, where n is the size of the array.
CMC: Cross product magnitude of two 2D vector.
(i.e., (x1, y1) -> (x2, y2) -> x1 * y2 - x2 * y1). Easy.
 
user image
15
 
@user202729 what exactly do you mean by '2D vector'
 
@user202729 Can you give an example? [20,10] and [2,3] gives 10?
 
2:43 PM
@HyperNeutrino ... mathematical vector in 2D Euclidean space?
 
isn't that just determinant of a matrix
 
... it is, apparently.
 
@user202729 oh I thought you meant that the vector was 2-dimensional :P so in R^2 then. ok makes sense
 
@PhiNotPi "Full of" doesn't necessarily imply "everyone" ... case in point. :D
 
@Adám I interpreted it as [20,10]; [2,3] -> 20*3 - 10*2 -> 60-20 = 40
 
2:44 PM
58 mins ago, by user202729
I'm not that sure about the ratio...
 
@PhiNotPi I think Dennis fits into the "really smart" category.
 
Interesting timing difference to create an instance of a class vs an anonymous class Try it online!
(in java)
 
@J.Sallé Ah, I misread. Thanks.
@user202729 APL (Dyalog Unicode), 5 bytes -/×∘⌽
 
@Poke that just in time compilation in action i guess
 
@user202729 J, 5 bytes -/ .*
 
2:59 PM
@user202729 Jelly, 5 bytes: Ṛ×_@/
(maybe Ṛ×ạ/ at 4 bytes if I'm supposed to return a positive result)
 
@EriktheOutgolfer Can't you just use ÆḊ?
 
@Adám uh, I'm not really sure (ÆḊ = determinant)
with reversed arguments it's Ṛ×_/
 
Using determinant it's ,ÆḊ.
 
no it's just ÆḊ
you get a 2-element list
 
Depends on the input format.
 
3:06 PM
APL, 5 bytes; J, 5 bytes; Jelly, 5 bytes
J is [...] a synthesis of APL
Jelly is [...] inspired by J.
nice
 
@user202729 SAX (Sharp APL), 3 bytes: -.×
 
@user202729 Pyt, 4 bytes: ↔←*₋
 
;-; My starboard is almost completely covered with pins
 
Can anyone visit meta stackoverflow (for example this) and see if there is any layout problem with comment?
 
Which comments?
I don't see any problem
 
3:21 PM
I get this.
 
Refresh perhaps?
 
I tried. Probably I should try clearing the cache.
 
Anonymous
@Mr.Xcoder Mine is completely covered. I'm in way too many rooms
 
@betseg I can.
@Mego You're in too many rooms? Look at my list of rooms.
(the "rejoin all" button is evil)
 
Anonymous
3:25 PM
@Mr.Xcoder At least you're not quartata
 
True dat
 
Anonymous
He's not in any right now, but he's usually in 100+ :P
 
@Mr.Xcoder i asked @user202729 :( there are some wrap related properties in that file
 
:( I hate it when I try to get to an user's profile from chat, but they're in too many rooms so their profile is out of my reach
 
3:31 PM
@Mr.Xcoder I think "user profile" is above the rooms list?
 
@user202729 Yup.
And the rooms list is far to high to fit my screen, so the button is inaccessible to me :)
 
look at the list of rooms that i'm in
 
\o/ PPCG v2 switched from "Posts" to "Challenges"
 
(if and only if you click at the online list at the right of the screen, there would not be that problem)
 
Anonymous
@Mr.Xcoder If you click on their avatar in the box on the side, it loads top-down from the cursor, rather than bottom-up like the ones in the chat box
 
Anonymous
3:32 PM
@Mr.Xcoder I thought we did that a while ago
 
@Mego Probably pulled far later?
Yesterday I'm quite sure it said "Posts"
 
Just tried, if the avatar is in the half up of the screen, it load top down, otherwise it load bottom up.
 
Anonymous
@Mr.Xcoder 7 days ago
 
@Mego Hm, good to know
 
Anonymous
So blame caching
 
3:34 PM
Hmm... I see that now 🤔
 
Anonymous
Which reminds me - I need to fix caching
 
CMC: Implement the following function: f:ℤ→ℤ. f(1)=0. f(2n)=2f(n)+1. f(2n+1)=2f(n).
2101 -> 1994
 
Oh cool. I just got another good badge! :)
 
Congrats! Which?
 
... something mods related?
 
3:40 PM
Nope, Famous Question.
... And he's so close to Socratic
 
@Mr.Xcoder BCḄ? Or the reverse of that?
 
I think BCḄ should work
 
(I don't remember which one is from binary and which one is to binary)
 
To binary is B. The dotted letters are for the inverses.
Bonus points for doing it in Triangularity without Python literal evaluation or Brain-flak.
 
20
Q: Recreate the ASCII-table as an ASCII-table

DJMcMayhemFrequently while I'm code-golfing, I'll want to know what the ASCII value of a certain character is. One of my favorite resources for quickly looking up all of the printable ASCII characters is ASCIItable.com. This has a really nice image that not only shows the printable ASCII characters and the...

Surprisingly
 
3:46 PM
How did that get 10k views mhm...
 
*gold not good
Beats me
 
@DJMcMayhem ಠ_ಠ You're one of the few people here who can actually correct the original message
 
@cairdcoinheringaahing ROs can edit messages after 2 mins? I don't think so.
 
@user202729 SAX (Sharp APL), 3 bytes, this time with link: -o×
 
@Mr.Xcoder I swear they can. Hold on, I'll go check
Huh, they can't.
@Mr.Xcoder ¯\_(ツ)_/¯ DJ will be a mod soon enough :P
 
3:52 PM
hopefully
 
Anonymous
The only special powers ROs get are pinning, removing stars, kicking, managing feeds, and timeouts
 
I know that, but thought I might have missed something
 
Anonymous
Just clarifying :)
 
@Mego And managing access to other users.
 
Anonymous
@Mr.Xcoder Oh right, I always forget about that because I never use gallery rooms
 
4:05 PM
They're somewhat relevant to non-gallery chat rooms too, when giving users with less than 20 rep access
 
@Mego What timeout?
 
@user202729 If there's spamming or harmful activities going on, you temporarily set a timeout (to make the users calm down)
 
Anonymous
@user202729 Room timeouts - they prevent all non-ROs and non-mods from chatting so that problems can be dealt with without them further escalating
 
Anonymous
I was wrong - ROs apparently can, too
 
Anonymous
Mods can allow users to have write access in a room while serving a chat suspension, I believe (unless Thomas was trolling me)
 
4:16 PM
TFW you start using an esolang to do something coding rather than a production language :/
 
@cairdcoinheringaahing Details? :P Sounds cool
Also something coding?
 
I'm using Add++ to output to TIO's limit rather than something sane, such as Python :P
 
@cairdcoinheringaahing I've actually done that a lot with SOGL (it's pretty useful when it has the built-ins needed :p)
 
@Mr.Xcoder ¯\_(ツ)_/¯ Close enough :P
 
@cairdcoinheringaahing No need. My job is to program in APL…
 
I can't get C++ to give me the value of an object without calling it's copy constructor and I already regret using this language.
 
Uh oh. I copied 5*128kb to the clipboard and now no tabs are loading :/
 
@Pavel Have you read the interview with Stroustrup about how C++ is good for the economy because it creates jobs?
 
@Adám Where can I get this job? :p
 
Anonymous
@Pavel Use references
 
4:29 PM
So I have an array of Foos called Bar. My function takes a parameter Foo foo. How do I set the first element of Bar to foo, and not a copy of foo? If I do Bar[0] = foo it tells me I get a copy.
 
@J.Sallé Would you be willing to move?
 
Anonymous
@Pavel Make an array of Foo*s
 
Anonymous
If you don't want copies, you need to use references or pointers. And since you're using an array, you can't use references.
 
Oh yeah, because C++ objects aren't automatically pointer types.
 
Anonymous
Yep
 
Anonymous
4:32 PM
C++ does copy-by-value everywhere unless you tell it not to
 
@J.Sallé Careers at Dyalog ← Also for internships and references to customers in need of APLers.
 
@Adám most certainly, yes. I don't think I know enough APL to apply for a job though :p
 
@J.Sallé Sounds like an internship might be a possibility then. Either way; send a CV to careers@.
@J.Sallé One major customer in the US is urgently looking for someone who would be trained until this (US) summer, and after then would be working 80% and further studying APL 20%.
 
@Adám Unfortunately I still need to finish college, hopefully this year.
But when I do I'll most certainly apply for an internship
 
My C++ code is an unholy combination of C arrays, C++ objects, malloc, and new, and I honestly don't see how large C++ projects are supposed to avoid this.
 
4:43 PM
@J.Sallé Great to hear. Maybe you should start taking contact now so that appropriate action may be taken in time. Do you finish this June?
 
@Pavel by using vectors
 
@Adám possibly, but December is more likely.
 
@HyperNeutrino I tried and it didn't work
 
oh ok
 
Yay, our security team is unblocking Reddit
Now I can goof off even more ;-)
 
4:45 PM
3 hours ago, by J. Sallé
@Adám efficiency is totally overrated anyway
 
Anonymous
@Pavel By using free, delete, and std::vector :P
 
error: return type 'IFoo' is an abstract class
Well shit
Wait, nevermind. More pointers.
 
Anonymous
Use pointers so you can use dynamic dispatch :P
 
Anonymous
Yep, pointers are the solution
 
Anonymous
But also don't return a pointer to a local
 
Anonymous
4:50 PM
Also use smart pointers
 
Excuse me ... I need your help. Why is my challenge getting a lot of upvotes but only a single now deleted answer? What can be improved?
 
@Mego I actually did try this, but the & operator didn't work on it, and I switched to new.
 
14
Q: Solve Hitori Puzzles (Fastest Algorithm)

Weijun ZhouIntroduction Write a solver for the Hitori puzzles with the lowest complexity of time. Challenge Your task is write a solver for the Hitori (ひとり, the word for "alone" in Japanese; The meaning of the game name is "Leave me alone") logical puzzles. The rules are as follows: You are presented w...

 
@WeijunZhou Probably because it is an interesting but hard challenge.
 
Anonymous
@WeijunZhou Probably because people are still working on solutions
 
4:52 PM
@WeijunZhou That's good. It means its a good challenge, but difficult. And ninja'd
 
OK. Thank you. I'll wait a few more days and see.
 
@WeijunZhou You can place a bounty to attract attention
If you have enough rep, that is
 
Anonymous
@Pavel std::shared_ptr<MyObject> obj_ptr = new MyObject();
 
Anonymous
@Pavel Not yet - it's only been one day
 
@Mego So those implicitly cast to and from MyObject*s?
 
4:54 PM
@Pavel Thank you for your suggestion, I may do that when I can. As for reputation I think I have enough.
 
Anonymous
@Pavel No. They wrap pointers, and you can use obj_ptr->foo just like you would use raw_ptr->foo.
 
Anonymous
You can also dereference them, but then that triggers a copy construction if you assign it, so it's probably not useful for you
 
Anonymous
Rather than using std::shared_ptrs as raw pointers, you use them instead of raw pointers
 
Anonymous
Also they automatically destroy the object pointed to by the wrapped raw pointer via delete - they do reference counting
 
So, they're garbage-collected. Neat.
 
Anonymous
4:57 PM
Yep, as of C++11, C++ actually has automatic garbage collection (but it's opt-in)
 
Wouldn't it be easier to opt-in to garbage collection than to use smart pointers?
 
Anonymous
Basically you use std::shared_ptrs like Python objects and you're golden :P Oh also use std::weak_ptr when you need a reference to a std::shared_ptr but you don't want that reference to force the object to stay alive
 
Anonymous
@Pavel Using smart pointers is how you opt-in to garbage collection
 
oic
What's the include for shared_ptr?
 
Anonymous
And there's also std::unique_ptr for when you don't need to pass it around, and instead tie its lifetime to some scope or enclosing object (like when it's a member variable of an object, or used only internally in a function)
 
Anonymous
4:59 PM
<memory>
 

« first day (2558 days earlier)      last day (1405 days later) »