Greg,

I figure it out. Adding const should work.

const Atom *atom = (*pCurrentROMol)[*atBegin];

Thanks.
Yingfeng

On Wed, Dec 12, 2018 at 10:21 AM Yingfeng Wang <ywang...@gmail.com> wrote:

> Greg,
>
> I figure out the problem. Removing "->get()" can solve the problem.
>
> Here is the updated version.
>
> boost::tie(firstB,lastB) = pCurrentROMol->getEdges();
>
> while(firstB!=lastB)
>
> {
>
>     auto bond = (*pCurrentROMol)[*firstB];
>
>     ...
>
>     sEdgeLabel += ((queryIsBondInRing(bond)) ? "ring|" : "linear|" );
>
>     ...
>
>     ++firstB;
>
> }
>
>
> The original version was
>
>
> boost::tie(firstB,lastB) = pCurrentROMol->getEdges();
>
> while(firstB!=lastB)
>
> {
>
>     boost::shared_ptr<Bond> bond = (*pCurrentROMol)[*firstB];
>
>     ...
>
>     sEdgeLabel += ((queryIsBondInRing(bond.get())) ? "ring|" : "linear|"
> );
>
>     ...
>
>     ++firstB;
>
> }
>
>
> However, I still have a question. Why "Atom *atom" and "Bond *bond" do not
> work? Yes, "auto" solves the problem, but I feel it just covers the
> essential issue.
>
>
> Thanks.
>
> Yingfeng
>
>
>
>
> On Wed, Dec 12, 2018 at 9:50 AM Yingfeng Wang <ywang...@gmail.com> wrote:
>
>> Greg,
>>
>> Thanks.  The first way does not work. I got the following error message.
>>
>> *Database.cpp:148:15: **error: **cannot initialize a variable of type
>> 'RDKit::Atom *'*
>>
>> *      with an rvalue of type 'const RDKit::Atom *'*
>>
>>         Atom *atom = (*pCurrentROMol)[*atBegin];
>>
>>
>> The second way, which uses "auto", works. I also updated the code for
>> bond and got a new error with the following error message.
>>
>> *Database.cpp:164:49: **error: **no member named 'get' in 'RDKit::Bond'*
>>
>>         sEdgeLabel += ((queryIsBondInRing(bond->get())) ? "ring|" :
>> "linear|" );
>>
>> *                                          ~~~~  ^*
>>
>> 1 error generated.
>>
>> Could you please confirm that the updated class Bond removes method
>> get()? If this is the case, which method should I use?
>>
>> Again, thank you very much for your help!
>>
>> Yingfeng
>>
>>
>>
>> On Wed, Dec 12, 2018 at 12:58 AM Greg Landrum <greg.land...@gmail.com>
>> wrote:
>>
>>> Hi Yingfeng,
>>>
>>> As part of the move over to Modern C++ we also changed the way atoms and
>>> bonds are stored in molecules: you now get raw pointers back instead of
>>> smart pointers.
>>> If you change your code from:
>>>  boost::shared_ptr<Atom> atom = (*pCurrentROMol)[*atBegin];
>>> to:
>>>  Atom *atom = (*pCurrentROMol)[*atBegin];
>>> or, even simpler:
>>>  auto atom = (*pCurrentROMol)[*atBegin];
>>>
>>> things should work.
>>> -greg
>>>
>>>
>>> On Wed, Dec 12, 2018 at 12:36 AM Yingfeng Wang <ywang...@gmail.com>
>>> wrote:
>>>
>>>> I am using the C++ library of RDKit on Mac. My C++ code works with
>>>> RDKit_2017_09_3. However, after I switch to RDKit 2018_03_4, I got the
>>>> following error when compiling my C++ source code.
>>>>
>>>> *Database.cpp:148:33: **error: **no viable conversion from 'const
>>>> RDKit::Atom *' to*
>>>>
>>>> *      'boost::shared_ptr<Atom>'*
>>>>
>>>>         boost::shared_ptr<Atom> atom = (*pCurrentROMol)[*atBegin];
>>>>
>>>> *                                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~*
>>>>
>>>> */usr/local/Cellar/boost/1.68.0/include/boost/smart_ptr/shared_ptr.hpp:358:21:
>>>> **note: *
>>>>
>>>>       candidate constructor not viable: no known conversion from
>>>>
>>>>       'const RDKit::Atom *' to 'boost::detail::sp_nullptr_t' (aka
>>>> 'nullptr_t')
>>>>
>>>>       for 1st argument
>>>>
>>>>     BOOST_CONSTEXPR shared_ptr( boost::detail::sp_nullptr_t )
>>>> BOOST_SP_N...
>>>>
>>>> *                    ^*
>>>>
>>>> */usr/local/Cellar/boost/1.68.0/include/boost/smart_ptr/shared_ptr.hpp:422:5:
>>>> **note: *
>>>>
>>>>       candidate constructor not viable: no known conversion from
>>>>
>>>>       'const RDKit::Atom *' to 'const boost::shared_ptr<RDKit::Atom>
>>>> &' for 1st
>>>>
>>>>       argument
>>>>
>>>>     shared_ptr( shared_ptr const & r ) BOOST_SP_NOEXCEPT : px( r.px ),
>>>> p...
>>>>
>>>> *    ^*
>>>>
>>>> I am using Clang on Mac. The version information is given as follows.
>>>>
>>>> g++ -v
>>>>
>>>> Configured with: --prefix=/Library/Developer/CommandLineTools/usr
>>>> --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
>>>>
>>>> Apple LLVM version 10.0.0 (clang-1000.10.44.4)
>>>>
>>>> Target: x86_64-apple-darwin18.2.0
>>>>
>>>> Thread model: posix
>>>>
>>>> I notice that "Starting with the 2018_03 release, the RDKit core C++
>>>> code is written in modern C++; for this release that means C++11. "
>>>>
>>>> Actually, I also use -std=c++11 when compiling my C++ source code. I
>>>> also tested RDKit 2018_09_1 and got the similar error. I am wondering how
>>>> to fix this problem.
>>>>
>>>> Thanks.
>>>>
>>>> Yingfeng
>>>>
>>>>
>>>> _______________________________________________
>>>> Rdkit-discuss mailing list
>>>> Rdkit-discuss@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>>>
>>>
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to