Skip to content

Commit e89ed39

Browse files
committed
Fix clang and MSVC 2017 build with C++17 enabled
1 parent a5c6c16 commit e89ed39

File tree

3 files changed

+33
-50
lines changed

3 files changed

+33
-50
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
BasedOnStyle: Mozilla
22
IndentWidth: 4
3+
TabWidth: 8
34
ColumnLimit: 160
45
BreakBeforeBraces: Custom
56
BraceWrapping:

include/jinja2cpp/value_ptr.hpp

-16
Original file line numberDiff line numberDiff line change
@@ -671,22 +671,6 @@ class value_ptr
671671
: ptr( std::move( value ) )
672672
{}
673673

674-
template< class... Args
675-
nsvp_REQUIRES_T(
676-
std::is_constructible<T, Args&&...>::value )
677-
>
678-
explicit value_ptr( nonstd_lite_in_place_t(T), Args&&... args )
679-
: ptr( nonstd_lite_in_place(T), std::forward<Args>(args)...)
680-
{}
681-
682-
template< class U, class... Args
683-
nsvp_REQUIRES_T(
684-
std::is_constructible<T, std::initializer_list<U>&, Args&&...>::value )
685-
>
686-
explicit value_ptr( nonstd_lite_in_place_t(T), std::initializer_list<U> il, Args&&... args )
687-
: ptr( nonstd_lite_in_place(T), il, std::forward<Args>(args)...)
688-
{}
689-
690674
#endif // nsvp_CPP11_OR_GREATER
691675

692676
explicit value_ptr( cloner_type const & cloner )

test/user_callable_test.cpp

+32-34
Original file line numberDiff line numberDiff line change
@@ -166,47 +166,47 @@ Hello
166166

167167
TEST(UserCallableTestSingle, ReflectedCallable)
168168
{
169-
std::string source = R"(
169+
std::string source = R"(
170170
{% set callable = reflected.basicCallable %}{{ callable() }}
171171
{{ reflected.basicCallable() }}
172172
{% set inner = reflected.getInnerStruct() %}{{ inner.strValue }}
173173
{% set innerValue = reflected.getInnerStructValue() %}{{ innerValue.strValue }}
174174
{{ innerReflected.strValue }}
175175
)";
176176

177-
Template tpl;
178-
auto parseRes = tpl.Load(source);
179-
EXPECT_TRUE(parseRes.has_value());
180-
if (!parseRes)
181-
{
182-
std::cout << parseRes.error() << std::endl;
183-
return;
184-
}
185-
186-
TestStruct reflected;
187-
auto innerReflected = std::make_shared<TestInnerStruct>();
188-
innerReflected->strValue = "!!Hello World!!";
189-
reflected.intValue = 100500;
190-
reflected.innerStruct = std::make_shared<TestInnerStruct>();
191-
reflected.innerStruct->strValue = "Hello World!";
192-
{
193-
jinja2::ValuesMap params;
194-
params["reflected"] = jinja2::Reflect(reflected);
195-
params["innerReflected"] = jinja2::Reflect(innerReflected);
196-
197-
std::string result = tpl.RenderAsString(params).value();
198-
std::cout << result << std::endl;
199-
std::string expectedResult = R"(
177+
Template tpl;
178+
auto parseRes = tpl.Load(source);
179+
EXPECT_TRUE(parseRes.has_value());
180+
if (!parseRes)
181+
{
182+
std::cout << parseRes.error() << std::endl;
183+
return;
184+
}
185+
186+
TestStruct reflected;
187+
auto innerReflected = std::make_shared<TestInnerStruct>();
188+
innerReflected->strValue = "!!Hello World!!";
189+
reflected.intValue = 100500;
190+
reflected.innerStruct = std::make_shared<TestInnerStruct>();
191+
reflected.innerStruct->strValue = "Hello World!";
192+
{
193+
jinja2::ValuesMap params;
194+
params["reflected"] = jinja2::Reflect(reflected);
195+
params["innerReflected"] = jinja2::Reflect(innerReflected);
196+
197+
std::string result = tpl.RenderAsString(params).value();
198+
std::cout << result << std::endl;
199+
std::string expectedResult = R"(
200200
100500
201201
100500
202202
Hello World!
203203
Hello World!
204204
!!Hello World!!
205205
)";
206-
EXPECT_EQ(expectedResult, result);
207-
}
208-
EXPECT_EQ(1L, innerReflected.use_count());
209-
EXPECT_EQ(1L, reflected.innerStruct.use_count());
206+
EXPECT_EQ(expectedResult, result);
207+
}
208+
EXPECT_EQ(1L, innerReflected.use_count());
209+
EXPECT_EQ(1L, reflected.innerStruct.use_count());
210210
}
211211

212212
struct UserCallableParamConvertTestTag;
@@ -255,12 +255,10 @@ TEST_P(UserCallableFilterTest, Test)
255255

256256
jinja2::ValuesMap params = PrepareTestData();
257257

258-
params["surround"] = MakeCallable(
259-
[](const std::string& val, const std::string& before, const std::string& after) {return before + val + after;},
260-
ArgInfo{"val"},
261-
ArgInfo{"before", false, ">>> "},
262-
ArgInfo{"after", false, " <<<"}
263-
);
258+
params["surround"] = MakeCallable([](const std::string& val, const std::string& before, const std::string& after) { return before + val + after; },
259+
ArgInfoT<const std::string&>{ "val" },
260+
ArgInfoT<const std::string&>{ "before", false, ">>> " },
261+
ArgInfoT<const std::string&>{ "after", false, " <<<" });
264262
params["joiner"] = MakeCallable([](const std::string& delim, const ValuesList& items) {
265263
std::ostringstream os;
266264
bool isFirst = true;

0 commit comments

Comments
 (0)