Self referencing objects in Optional #292
-
|
Hi Team, I am trying to use the self referencing objects in the optional, but I am getting error like below. ~\workspace\jsoncons\include\jsoncons\detail\optional.hpp(53,15): error C2079: 'jsoncons::detail::optionalns::hiking_reputon::value_' uses undefined class 'ns::hiking_reputon' And, the class I have declared as below. Do, please let me know if I am doing any wrong here. Thanks in advance for your time and help. --Dinesh |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
That wouldn't work with For self referencing objects, I would suggest using |
Beta Was this translation helpful? Give feedback.
That wouldn't work with
std::optionaleither (jsoncons::optionalis typedefed tostd::optionalif C++17 is detected.) Whetherjsonconsorstd,optional<T>requires a complete type, it stores aTwithin the optional object, not on the heap.For self referencing objects, I would suggest using
std::unique_ptrinstead.