Problem 1739

Summary: Use of G4Cache in GPS classes causes compilation issues with compiler generated copy-constructor
Product: Geant4 Reporter: Andrea Dotti <andrea.dotti>
Component: eventAssignee: Andrea Dotti <andrea.dotti>
Status: RESOLVED FIXED    
Severity: minor    
Priority: P5    
Version: 10.1   
Hardware: All   
OS: All   

Description Andrea Dotti 2015-04-28 00:27:37 CEST
As reported by GATE collaboration.
 
Consider the following code:
class MyClass {
G4SPSPosDistribution my_helper;
}

This code will not compile when copy constructor is compiler-generated because G4SPSPosDistribution contains a G4Cache<> data-field that is not-copyable.

While the problem can be addressed at the user-code level (e.g. disabling copy-ctr in user classes), a proper strategy should be implemented to solve the issue in G4 code. 

From a first analysis two strategies seems possible:
A) Transform G4Cache to be copiable
B) Provide a copy-ctr (and ass. operator) of contaier classes (e.g. every class contains a G4Cache<> object) that does not copy the cache and instead initializes a new one.

B) has the drawback of breaking the semantic of the copy-ctr. A) may be more complex to implement.

Andrea
Comment 1 Andrea Dotti 2015-05-09 12:37:42 CEST
After some investigation. It is probably possible to solve this issue writing a custom copy constructor and assignment operator in G4Cache. Being investigated: needs unit test
Comment 2 Andrea Dotti 2015-05-18 09:52:02 CEST
Testing possible solution in global-V10-01-10: custom copy constructor and assignment operator.
Comment 3 Andrea Dotti 2015-05-26 20:16:39 CEST
Fixed in global-V10-01-10