# G4GenericMessenger and std::optional

**URL:** <https://geant4-forum.web.cern.ch/t/g4genericmessenger-and-std-optional/6204>\
**Category:** Ideas and Requirements\
**Created:** [September 23, 2021, 6:51am UTC](https://geant4-forum.web.cern.ch/t/g4genericmessenger-and-std-optional/6204 "2021-09-23T06:51:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacek](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/jacek/32/4100_2.png) [@jacek](https://geant4-forum.web.cern.ch/u/jacek)\
**Post date:** [September 23, 2021, 6:51am UTC](https://geant4-forum.web.cern.ch/t/g4genericmessenger-and-std-optional/6204/1 "2021-09-23T06:51:38Z")

</div>

I couldn’t really find an appropriate category in which to post this question. This seemed like the least inappropriate one.

I would like to use `G4GenericMessenger` to set fields of type `std::optional<whatever>` where, in the first instance, `whatever = G4String`. This appears not to work. It appears to be because `G4AnyType` (on which the former depends) does not understand `std::optional`.

Is it possible to set `std::optional`s with `G4GenericMessenger`?
