Belle II Software development
icc.test.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9/*
10This file tests whether the C++ compiler of Intel implements C++.
11*/
12
13#include <gtest/gtest.h>
14
15namespace {
16
18 template<class T>
19 class Wrapper {
20
21 public:
23 explicit Wrapper(T t) : m_t(t)
24 {}
25
26 public:
31 /*explicit*/ operator T& ()
32 { return m_t; }
33
34 private:
36 T m_t;
37 };
38
39 TEST(IntelCompiler, static_cast_calls_conversion_operator_template)
40 {
41 Wrapper<int> wrappedInt(6);
42
43 int& i1(wrappedInt.operator int& ());
44 int& i2(static_cast<int&>(wrappedInt));
45 int& i3(wrappedInt);
46
47 EXPECT_EQ(6, i1);
48 EXPECT_EQ(6, i2);
49 EXPECT_EQ(6, i3);
50 }
51
52
54 class IntWrapper {
55
56 public:
58 explicit IntWrapper(int t) : m_t(t)
59 {}
60
61 public:
66 /*explicit*/ operator int& ()
67 { return m_t; }
68
69 private:
71 int m_t;
72 };
73
74 TEST(IntelCompiler, static_cast_calls_conversion_operator_notemplate)
75 {
76 IntWrapper wrappedInt(6);
77
78 int& i1(wrappedInt.operator int& ());
79 int& i2(static_cast<int&>(wrappedInt));
80 int& i3(wrappedInt);
81
82 EXPECT_EQ(6, i1);
83 EXPECT_EQ(6, i2);
84 EXPECT_EQ(6, i3);
85 }
86
87}