Profile

Cover photo
Alf Steinbach
Works at n/a
Attended NTH (Norsk Teknisk Høgskole, now NTNU)
Lives in Oslo
60 followers|5,327 views
AboutPostsPhotosYouTube

Stream

Alf Steinbach

Shared publicly  - 
 
I posted this question after a strong indication that at least some physicists believe the answer is "yes" but are unwilling to state that openly. So far, no comments and no answers. Well it's only half an hour or so, and I do not know the answer for sure, but still, that silence reinforces my growing belief that even PHYSICS today has devolved to group conformity (a.k.a. religion) instead of rational science, logic and facts.
1
Add a comment...

Alf Steinbach

Shared publicly  - 
1
Add a comment...

Alf Steinbach

Shared publicly  - 
 
The main problem with the reconstruct approach for move assignment is that it requires every derived class to have a user-defined move assignment operator that does not call the base class' move assignment operator. Otherwise the reconstruction introduces formal UB, and in practice the problem of incorrect vtable pointer for an object of a polymorphic class. And this problem is very easy to introduce inadvertently, since the DEFAULT (with a compile-generated move assignment operator in a derived class) is UB.

The reconstruct approach as applied for copy assignment has the additional in-practice problem of exception safety, where the assignee is destroyed before it's known whether copying will succeed.

Formally exception safety is also a problem for move assignment, but in practice move constructors will not throw.
Most of the time we don't have to worry about defining copy/move constructors and assignment operators -- the compiler happily generates them for us. Sometimes, however, we must do the dirty work ourselves and code them up ma...
1
Eugene Yakubovich's profile photo
 
I probably should not have dismissed the concerns as minor. And I view this not as an idiom but as a tool that can sometimes be used. If a class has virtuals (and thus a vtable) and run-time polymorphism then it's probably created on the heap, managed via a smart pointer and probably outlaws assignments anyway. For the cases that don't involve virtuals (much more often than not in my code), calling base class operator= should be OK in practice (although I didn't realize that it's formally UB). Using this trick in both base and derived classes is, of course, very inefficient.

As for exception safety, yes, it's horrible but then again so is a default generated member-wise version (which doesn't always deliver basic-guarantee). If your copy constructor can throw -- don't use it. Hopefully your class has a no-throw swap and copy/swap can be used for copy-assignment and this trick for move-assignment.

Again, this is not meant to be a universal idiom -- just a utility that can be used in places where it's safe. Having said that, maybe the number of gotcha's does outweigh the benefits of ever using that. 
Add a comment...

Alf Steinbach

Shared publicly  - 
1
Add a comment...

Alf Steinbach

Shared publicly  - 
1
Add a comment...

Alf Steinbach

Shared publicly  - 
 
New posting at (or is that "in"?) my "Lessons in Windows API programming (C++)" sub-blog.
Teaching GUI programming at the Windows API level, in C++.
From the ground up.
1
Add a comment...
Have him in circles
60 people
David Cravey's profile photo
Happy Mittal's profile photo
Michal Mocny's profile photo
Catherine Sea's profile photo
Johannes Schaub's profile photo
David Vandevoorde's profile photo
Billy Baker's profile photo
Dominique Genique's profile photo
potato potato's profile photo

Alf Steinbach

Shared publicly  - 
 
From a walk to Vikan on 9th of May, 2014.
1
Add a comment...

Alf Steinbach

Shared publicly  - 
1
Add a comment...

Alf Steinbach

Shared publicly  - 
1
Add a comment...

Alf Steinbach

Shared publicly  - 
1
Add a comment...

Alf Steinbach

Shared publicly  - 
 
I think it's a good idea if we all report the "What's hot on Google+" postings as *SPAM*. Can't hurt. May do some good.
1
Add a comment...

Alf Steinbach

Shared publicly  - 
 
I finally sent feedback to Google asking them turn off the freaking "What's hot on Google+".

Explaining that forcing yourself on someone without that someone's consent, is rape-like.

Well yet it's pretty dumb trying to explain to someone forcing themselves on you, that you don't really like it, but I guess if one does not ever actually say "No" then at least in theory that leaves some room for misunderstanding.
1
Alf Steinbach's profile photo
 
I don't understand, the "What's hot on Google+" disappeared immediately, and now instead I have a link to it on the left :-). Google moves in mysterious ways. That's for sure!
Add a comment...
People
Have him in circles
60 people
David Cravey's profile photo
Happy Mittal's profile photo
Michal Mocny's profile photo
Catherine Sea's profile photo
Johannes Schaub's profile photo
David Vandevoorde's profile photo
Billy Baker's profile photo
Dominique Genique's profile photo
potato potato's profile photo
Work
Employment
  • n/a
    n/a, 2002 - present
  • Mogul Technology (now Kantega)
    Senior Consultant, 2001 - 2002
  • Andersen Consulting (now Accenture)
    Senior Consultant, 1997 - 2001
  • Bodø College (now Bodø University)
    Norwegian "Amanuensis" (assistant professor?), 1994 - 1996
  • Bodin High School
    Norwegian "adjunkt" (essentially, a high school teacher), 1991 - 1994
Places
Map of the places this user has livedMap of the places this user has livedMap of the places this user has lived
Currently
Oslo
Previously
Bø i Vesterålen - Bodø - Edinburgh - Kongsberg
Story
Tagline
What's a Google+ tagline? Who knows. It should have been explained.
Introduction
I'm one of the moderators of the [comp.lang.c++.moderated] Usenet group. Although I haven't worked professionally in software development for a long time, I'm still active on Usenet and on StackOverflow helping both novices and professionals, mostly with C++ programming and software development in general. So, I haven't lost the old interest in software development. I even blog now and then. :-)
Bragging rights
I may, through an unfortunate remark in a meeting, have been the one responsible for the adoption of 3 spaces per indent at Accenture.
Education
  • NTH (Norsk Teknisk Høgskole, now NTNU)
    NIF project mgmt. course, 1990
  • Heriot Watt University
    Computer Science, 1985 - 1987
  • Kongsberg College of Engineering
    Software Development, 1982 - 1985
  • Norwegian Army
    Oblig. service, border guard against Russia, 1981 - 1982
  • Sortland High School
    "natural sciences", 1978 - 1981
Basic Information
Gender
Male