{"action":"closed","issue":{"url":"https://api.github.com/repos/USCiLab/cereal/issues/283","repository_url":"https://api.github.com/repos/USCiLab/cereal","labels_url":"https://api.github.com/repos/USCiLab/cereal/issues/283/labels{/name}","comments_url":"https://api.github.com/repos/USCiLab/cereal/issues/283/comments","events_url":"https://api.github.com/repos/USCiLab/cereal/issues/283/events","html_url":"https://github.com/USCiLab/cereal/issues/283","id":152053081,"number":283,"title":"Feature Request: Be able to call shared_from_this after an object has been constructed in load_and_construct","user":{"login":"M2tM","id":923621,"avatar_url":"https://avatars.githubusercontent.com/u/923621?v=3","gravatar_id":"","url":"https://api.github.com/users/M2tM","html_url":"https://github.com/M2tM","followers_url":"https://api.github.com/users/M2tM/followers","following_url":"https://api.github.com/users/M2tM/following{/other_user}","gists_url":"https://api.github.com/users/M2tM/gists{/gist_id}","starred_url":"https://api.github.com/users/M2tM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/M2tM/subscriptions","organizations_url":"https://api.github.com/users/M2tM/orgs","repos_url":"https://api.github.com/users/M2tM/repos","events_url":"https://api.github.com/users/M2tM/events{/privacy}","received_events_url":"https://api.github.com/users/M2tM/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/USCiLab/cereal/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/USCiLab/cereal/milestones/5","html_url":"https://github.com/USCiLab/cereal/milestones/v1.2.0","labels_url":"https://api.github.com/repos/USCiLab/cereal/milestones/5/labels","id":634032,"number":5,"title":"v1.2.0","description":"","creator":{"login":"AzothAmmo","id":1634639,"avatar_url":"https://avatars.githubusercontent.com/u/1634639?v=3","gravatar_id":"","url":"https://api.github.com/users/AzothAmmo","html_url":"https://github.com/AzothAmmo","followers_url":"https://api.github.com/users/AzothAmmo/followers","following_url":"https://api.github.com/users/AzothAmmo/following{/other_user}","gists_url":"https://api.github.com/users/AzothAmmo/gists{/gist_id}","starred_url":"https://api.github.com/users/AzothAmmo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AzothAmmo/subscriptions","organizations_url":"https://api.github.com/users/AzothAmmo/orgs","repos_url":"https://api.github.com/users/AzothAmmo/repos","events_url":"https://api.github.com/users/AzothAmmo/events{/privacy}","received_events_url":"https://api.github.com/users/AzothAmmo/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":32,"state":"open","created_at":"2014-04-18T17:13:10Z","updated_at":"2016-05-01T06:05:03Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2016-04-30T21:08:08Z","updated_at":"2016-05-01T06:05:03Z","closed_at":"2016-05-01T06:05:03Z","body":"It would be hugely beneficial for quite a few of my systems to be able to call shared_from_this after construct().  In many of my things when I create them I utilize shared_ptr in interfaces and being able to pass a shared_ptr after construction is part of my factory methods that make these objects in the first place.  In this regard, being able to do the same work my factory methods are doing in the deserialization process would be super streamlined.\r\n\r\nIs there a technical reason that makes it impossible for shared_from_this to return a valid shared_ptr?\r\n\r\nOr, atlernatively, is there a way you could expose the shared_ptr that's currently being populated via the cereal::construct object?  IE: Could I call construct.shared_ptr() or construct.shared_from_this() to get the shared_ptr.\r\n\r\n```\r\n#include <stringstream>\r\n#include <iostream>\r\n#include \"cereal/cereal.hpp\"\r\n\r\nstruct SharedFromThisPlease : public std::enable_shared_from_this<SharedFromThisPlease> {\r\n\tvirtual ~SharedFromThisPlease(){}\r\n\r\n\ttemplate <class Archive>\r\n\tvoid serialize(Archive & archive) {}\r\n\r\n\ttemplate <class Archive>\r\n\tstatic void load_and_construct(Archive & archive, cereal::construct<SharedFromThisPlease> &construct) {\r\n\t\tconstruct();\r\n\t\tauto selfReference = construct->shared_from_this(); //Breaks here currently\r\n\t}\r\n};\r\n\r\n#include \"cereal/archives/json.hpp\"\r\n\r\nint main(){\r\n\tstd::stringstream stream;\r\n\r\n\t{\r\n\t\tcereal::JSONOutputArchive archive(stream);\r\n\t\tarchive(std::make_shared<SharedFromThisPlease>());\r\n\t}\r\n\r\n\tstd::shared_ptr<SharedFromThisPlease> loadedResult;\r\n\t{\r\n\t\tcereal::JSONInputArchive archive(stream);\r\n\t\tarchive(loadedResult);\r\n\t}\r\n}\r\n```"}}