How to deal with OTK 'optional' conflicting with C++11 std::optional
Hi all,
OTK defines 'optional' in ciptype.h with the simple '#define optional' statement. Why anybody would use preprocessor definitions in C++ API made for public consumption is beyond comprehension...
Anything based on std::optional (or boost::optional) causes compilation errors. The only way I had figured out how to deal with it was to use dependency injection design pattern. This approach is extremely inefficient in terms of writing code or maintaining it. What it boils down to is:
//wrapper.hxx
//wrapper.cxx includes service.hxx - thus avoids polluting wrapper.hxx with std::optional
class Service; //forward
class Wrapper
{
Service service;
Wrapper();
}
//service.hxx and service.cxx
class Service
{
std::optional some_value;
}
//client.cxx
#include <wrapper.hxx>
class OTK_Client
{
Wrapper *proxy;
OTK_Client() { proxy = new Wrapper();}
}
Does anybody have a better idea how to handle this?
TIA.
Feliks.
This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

