Repository navigation
Self referencing objects in Optional #292
Answered
by
danielaparker
dineshkumar02
asked this question in
General
|
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 |
Answered by
danielaparker
Dec 19, 2020
Replies: 1 comment 2 replies
|
That wouldn't work with For self referencing objects, I would suggest using |
2 replies
Answer selected by
dineshkumar02
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.