| Summary: | Use of G4Cache in GPS classes causes compilation issues with compiler generated copy-constructor | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Andrea Dotti <andrea.dotti> |
| Component: | event | Assignee: | Andrea Dotti <andrea.dotti> |
| Status: | RESOLVED FIXED | ||
| Severity: | minor | ||
| Priority: | P5 | ||
| Version: | 10.1 | ||
| Hardware: | All | ||
| OS: | All | ||
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 Testing possible solution in global-V10-01-10: custom copy constructor and assignment operator. Fixed in global-V10-01-10 |
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