Boost logo

Boost Users :

Subject: Re: [Boost-users] 1.56.0 beta release candidate 2 available for testing
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2014-07-16 15:59:00


Please ignore the following part of my previous email:

On Wed, Jul 16, 2014 at 9:14 PM, Klaim - Joël Lamotte <mjklaim_at_[hidden]>
wrote:

> Then I hit the same link error I reported previously, from optional code
> apparently:
>
> 3>typevaluemap.obj : error LNK2019: unresolved external symbol "class
> std::basic_ostream<char,struct std::char_traits<char> > & __cdecl
> boost::operator<<<char,struct std::char_traits<char>,int>(class
> std::basic_ostream<char,struct std::char_traits<char> > &,class
> boost::optional<int> const &)" (??$?6DU?$char_traits_at_D@std@@H_at_boost
> @@YAAAV?$basic_ostream_at_DU?$char_traits_at_D@std@@@std@@AAV12_at_ABV?$optional_at_H
> @0@@Z) referenced in function "void __cdecl
> testing_internal::DefaultPrintNonContainerTo<class boost::optional<int>
> >(class boost::optional<int> const &,class std::basic_ostream<char,struct
> std::char_traits<char> > *)" (??$DefaultPrintNonContainerTo_at_V?$optional_at_H
> @boost@@@testing_internal@@YAXABV?$optional_at_H@boost@@PAV?$basic_ostream_at_DU
> ?$char_traits_at_D@std@@@std@@@Z)
>
> I investigated further and found that this error only occur in when this
> function have been compiled:
>
> template< class ValueType >
> inline boost::optional<ValueType> TypeValueMap::read() const
> {
> auto* slot = m_slot_index.find<ValueType>();
> if( slot && slot->value )
> {
> return slot->value.get();
> }
> return {};
> }
>
> With slot's type looking like this:
>
> template< class ValueType >
> struct SlotOf : public Slot
> {
> boost::optional<ValueType> value;
> //...
>
> Maybe I did something wrong here?
> However, the link error report suggest that some boost optional's testing
> function is called when it shouldn't (this appear when I'm compiling my own
> project).
>

I found that it's a link issue related to GTest macros which apparently
generate this error when I try to test the optional result implicitely:

#include <gtest/gtest.h>
#include <boost/optional.hpp>

TEST( blah, blah )
{
    boost::optional<int> k = 42;
    EXPECT_EQ( 42, k ); // this will trigger the link error
}

Replacing the pointed line by
   EXPECT_EQ( 42, k.get() ); // OK

seems to fix the issue.

Sorry for the noise!



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net