[llvm-commits] [llvm] r146827 - in /llvm/trunk: include/llvm/ADT/VariadicFunction.h unittests/ADT/VariadicFunctionTest.cpp
Chandler Carruth
chandlerc at gmail.com
Sat Dec 17 02:20:16 PST 2011
Author: chandlerc
Date: Sat Dec 17 04:20:15 2011
New Revision: 146827
URL: http://llvm.org/viewvc/llvm-project?rev=146827&view=rev
Log:
As Doug pointed out (and I really should know), it is perfectly easy to
make VariadicFunction actually be trivial. Do so, and also make it look
more like your standard trivial functor by making it a struct with no
access specifiers. The unit test is updated to initialize its functors
properly.
Modified:
llvm/trunk/include/llvm/ADT/VariadicFunction.h
llvm/trunk/unittests/ADT/VariadicFunctionTest.cpp
Modified: llvm/trunk/include/llvm/ADT/VariadicFunction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/VariadicFunction.h?rev=146827&r1=146826&r2=146827&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/VariadicFunction.h (original)
+++ llvm/trunk/include/llvm/ADT/VariadicFunction.h Sat Dec 17 04:20:15 2011
@@ -103,10 +103,7 @@
/// fixed leading arguments and up-to 32 optional arguments.
template <typename ResultT, typename ArgT,
ResultT (*Func)(ArrayRef<const ArgT *>)>
-class VariadicFunction {
- public:
- VariadicFunction() {}
-
+struct VariadicFunction {
ResultT operator()() const {
return Func(ArrayRef<const ArgT *>());
}
@@ -153,10 +150,7 @@
template <typename ResultT, typename Param0T, typename ArgT,
ResultT (*Func)(Param0T, ArrayRef<const ArgT *>)>
-class VariadicFunction1 {
- public:
- VariadicFunction1() {}
-
+struct VariadicFunction1 {
ResultT operator()(Param0T P0) const {
return Func(P0, ArrayRef<const ArgT *>());
}
@@ -203,10 +197,7 @@
template <typename ResultT, typename Param0T, typename Param1T, typename ArgT,
ResultT (*Func)(Param0T, Param1T, ArrayRef<const ArgT *>)>
-class VariadicFunction2 {
- public:
- VariadicFunction2() {}
-
+struct VariadicFunction2 {
ResultT operator()(Param0T P0, Param1T P1) const {
return Func(P0, P1, ArrayRef<const ArgT *>());
}
@@ -255,10 +246,7 @@
template <typename ResultT, typename Param0T, typename Param1T,
typename Param2T, typename ArgT,
ResultT (*Func)(Param0T, Param1T, Param2T, ArrayRef<const ArgT *>)>
-class VariadicFunction3 {
- public:
- VariadicFunction3() {}
-
+struct VariadicFunction3 {
ResultT operator()(Param0T P0, Param1T P1, Param2T P2) const {
return Func(P0, P1, P2, ArrayRef<const ArgT *>());
}
Modified: llvm/trunk/unittests/ADT/VariadicFunctionTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/VariadicFunctionTest.cpp?rev=146827&r1=146826&r2=146827&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/VariadicFunctionTest.cpp (original)
+++ llvm/trunk/unittests/ADT/VariadicFunctionTest.cpp Sat Dec 17 04:20:15 2011
@@ -22,7 +22,7 @@
S += *Args[i];
return S;
}
-const VariadicFunction<std::string, std::string, StringCatImpl> StringCat;
+const VariadicFunction<std::string, std::string, StringCatImpl> StringCat = {};
TEST(VariadicFunctionTest, WorksForClassTypes) {
EXPECT_EQ("", StringCat());
@@ -45,7 +45,7 @@
Result += *Args[i];
return Result;
}
-const VariadicFunction<long, int, SumImpl> Sum;
+const VariadicFunction<long, int, SumImpl> Sum = {};
TEST(VariadicFunctionTest, WorksForPrimitiveTypes) {
EXPECT_EQ(0, Sum());
@@ -65,7 +65,7 @@
return Chars;
}
const VariadicFunction1<int, std::string *, std::string,
- StringAppendImpl> StringAppend;
+ StringAppendImpl> StringAppend = {};
TEST(VariadicFunction1Test, Works) {
std::string S0("hi");
@@ -93,7 +93,7 @@
++(*NumInRange);
}
const VariadicFunction3<void, int *, int, int, int,
- CountInRangeImpl> CountInRange;
+ CountInRangeImpl> CountInRange = {};
TEST(VariadicFunction3Test, Works) {
int N = -1;
More information about the llvm-commits
mailing list