Boost logo

Boost Users :

Subject: Re: [Boost-users] [BOOST]BOOST_AUTO_TEST_CASE_TEMPLATEvs BOOST_AUTO_TEST_CASE
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2014-01-12 21:50:29


Hemanth Choudary M V (RBEI/ETA1 <HemanthChoudary.MV <at> in.bosch.com>
writes:

> Why is the behaviour different in these 2 scenarios?
> How is Boost able to differenciate between the 2 test cases in Scenario1?

I think what it essentially comes to is this:

If you have in header H:

class A{ public: void test_method(); }

void A::test_method() {} // note NO inline

and include this header in 2 C++ files A and B linker will complain.

If on the other hand you have this in H:

template<typename Foo>
class A{ public: void test_method(); }

template<typename Foo>
void A<Foo>::test_method() {} // inline implied

Linker is required to merge multiple definitions from different translation
units and program builds fine.

These are rules of C++.

HTH,
Gennadiy


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