File indexing completed on 2024-04-06 12:11:56
0001 #include "FWCore/Concurrency/interface/ThreadSafeAddOnlyContainer.h"
0002
0003 #include <iostream>
0004 #include <string>
0005
0006 namespace {
0007 template <typename U, typename V>
0008 class X {
0009 public:
0010 X(U const& a, V const& b, double c) : a_(a), b_(b), c_(c) { std::cout << "Constructing " << a_ << std::endl; }
0011 ~X() { std::cout << "~X " << a_ << std::endl; }
0012 U a_;
0013 V b_;
0014 double c_;
0015 };
0016
0017 class Y {
0018 public:
0019 Y() { std::cout << "constructing Y" << std::endl; }
0020 ~Y() { std::cout << "~Y" << std::endl; }
0021 };
0022 }
0023
0024 int main() {
0025 edm::ThreadSafeAddOnlyContainer<int> container1;
0026 int* ptr1 = container1.makeAndHold(11);
0027
0028 if (*ptr1 != 11)
0029 abort();
0030
0031 edm::ThreadSafeAddOnlyContainer<X<std::string, int> > container2;
0032 X<std::string, int>* ptr2 = container2.makeAndHold(std::string("FOO"), 11, 21.0);
0033
0034 if (ptr2->a_ != "FOO" || ptr2->b_ != 11 || ptr2->c_ != 21.0)
0035 abort();
0036
0037 X<std::string, int>* ptr3 = container2.makeAndHold(std::string("BAR"), 111, 121.0);
0038
0039 if (ptr3->a_ != "BAR" || ptr3->b_ != 111 || ptr3->c_ != 121.0)
0040 abort();
0041
0042 edm::ThreadSafeAddOnlyContainer<X<std::string, int> > container3;
0043
0044 edm::ThreadSafeAddOnlyContainer<Y> container4;
0045 container4.makeAndHold();
0046 container4.makeAndHold();
0047
0048 return 0;
0049 }