Skip to content

Commit 2358292

Browse files
author
Fytch
committed
change the default style of initialization from {} to ()
1 parent ac8e92f commit 2358292

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

include/ProgramOptions.hxx

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#define PROGRAMOPTIONS_ASSERT(Expression, Message)\
4242
do {\
4343
if(!(Expression))\
44-
throw std::logic_error{ ("ProgramOptions.hxx:" + std::to_string(__LINE__) + ": ") + (Message) };\
44+
throw std::logic_error(("ProgramOptions.hxx:" + std::to_string(__LINE__) + ": ") + (Message));\
4545
} while(0)
4646
#else // PROGRAMOPTIONS_EXCEPTIONS
4747
#ifdef PROGRAMOPTIONS_DEBUG
@@ -106,7 +106,7 @@ namespace po {
106106
#endif // PROGRAMOPTIONS_WINDOWS
107107

108108
color_resetter(std::ostream& stream, color_t color)
109-
: m_stream(stream) { // don't use an initializer list here because of gcc-4.8.5
109+
: m_stream(stream) {
110110
#ifdef PROGRAMOPTIONS_WINDOWS
111111
m_stream << std::flush;
112112
m_console = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -211,7 +211,7 @@ namespace po {
211211
// Compatibility stuff for the lack of C++14 support
212212
template<typename T, typename... args_t>
213213
std::unique_ptr<T> make_unique(args_t&&... args) {
214-
return std::unique_ptr<T>{ new T{ std::forward<args_t>(args)... } };
214+
return std::unique_ptr<T>(new T(std::forward<args_t>(args)...));
215215
}
216216

217217
template<typename T, T... i>
@@ -291,7 +291,7 @@ namespace po {
291291

292292
public:
293293
explicit repeat(std::size_t count, char character)
294-
: m_count{ count }, m_character{ character } {
294+
: m_count(count), m_character(character) {
295295
}
296296

297297
friend std::ostream& operator<<(std::ostream& stream, repeat const& object) {
@@ -419,7 +419,7 @@ namespace po {
419419
template<typename T>
420420
T pow(T base, int exp) {
421421
const T result = pow(base, static_cast<unsigned>(std::abs(exp)));
422-
return exp >= 0 ? result : T{ 1 } / result;
422+
return exp >= 0 ? result : T(1) / result;
423423
}
424424

425425
template<typename T, unsigned i>
@@ -449,17 +449,17 @@ namespace po {
449449
template<typename T>
450450
struct parsing_report {
451451
error_code error = error_code::none;
452-
const T value{};
452+
T value; // should be optional
453453

454454
parsing_report() = default;
455455
parsing_report(error_code error)
456-
: error{ error } {
456+
: error(error) {
457457
}
458458
parsing_report(T const& value)
459-
: value{ value } {
459+
: value(value) {
460460
}
461461
parsing_report(T&& value)
462-
: value{ std::move(value) } {
462+
: value(std::move(value)) {
463463
}
464464

465465
bool good() const {
@@ -523,7 +523,7 @@ namespace po {
523523
}
524524
template<typename forward_iterator_t, typename... args_t>
525525
bool expect(forward_iterator_t& first, forward_iterator_t last, args_t&&... args) {
526-
forward_iterator_t first_copy{ first };
526+
forward_iterator_t first_copy(first);
527527
const bool result = detail::expect_impl(first_copy, last, std::forward<args_t>(args)...);
528528
if(result)
529529
first = first_copy;
@@ -604,7 +604,7 @@ namespace po {
604604
if(decimals >= max_decimals)
605605
if(decimals > max_decimals || exp > max)
606606
return error_code::out_of_range;
607-
const T fac = pow(T{ 10 }, exp);
607+
const T fac = pow(T(10), exp);
608608
const T mant = result;
609609
result *= fac;
610610
if(result / fac != mant)
@@ -771,10 +771,10 @@ namespace po {
771771

772772
value() = default;
773773
explicit value(string_t const& object)
774-
: string{ object } {
774+
: string(object) {
775775
}
776776
explicit value(string_t&& object)
777-
: string{ std::move(object) } {
777+
: string(std::move(object)) {
778778
}
779779
};
780780

@@ -906,7 +906,7 @@ namespace po {
906906
public:
907907
template<typename... args_t>
908908
explicit callback_storage(args_t&&... args)
909-
: m_invocable{ std::forward<args_t>(args)... } {
909+
: m_invocable(std::forward<args_t>(args)...) {
910910
}
911911
};
912912

@@ -1116,7 +1116,7 @@ namespace po {
11161116
value_iterator() {
11171117
}
11181118
explicit value_iterator(underlying_t const& underlying)
1119-
: m_underlying{ underlying } {
1119+
: m_underlying(underlying) {
11201120
}
11211121

11221122
reference operator*() const {
@@ -1150,7 +1150,7 @@ namespace po {
11501150
return *this;
11511151
}
11521152
value_iterator operator++(int) {
1153-
value_iterator result{ *this };
1153+
value_iterator result(*this);
11541154
++*this;
11551155
return result;
11561156
}
@@ -1159,7 +1159,7 @@ namespace po {
11591159
return *this;
11601160
}
11611161
value_iterator operator--(int) {
1162-
value_iterator result{ *this };
1162+
value_iterator result(*this);
11631163
--*this;
11641164
return result;
11651165
}
@@ -1339,7 +1339,7 @@ namespace po {
13391339
return result;
13401340
}
13411341
parsing_report<value> make_value(std::string const& str) const {
1342-
return make_value(std::string{ str });
1342+
return make_value(std::string(str));
13431343
}
13441344
template<typename T>
13451345
parsing_report<value> make_value(T const& integer, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr) const {
@@ -1468,7 +1468,7 @@ namespace po {
14681468
return begin();
14691469
}
14701470
reverse_iterator rbegin() const {
1471-
return reverse_iterator{ end() };
1471+
return reverse_iterator(end());
14721472
}
14731473
const_reverse_iterator crbegin() const {
14741474
return rbegin();
@@ -1484,7 +1484,7 @@ namespace po {
14841484
return end();
14851485
}
14861486
reverse_iterator rend() const {
1487-
return reverse_iterator{ begin() };
1487+
return reverse_iterator(begin());
14881488
}
14891489
const_reverse_iterator crend() const {
14901490
return rend();
@@ -1493,15 +1493,15 @@ namespace po {
14931493
template<value_type type>
14941494
value_iterator<type, iterator> begin() const {
14951495
assert_iterator_type<type>();
1496-
return value_iterator<type, iterator>{ begin() };
1496+
return value_iterator<type, iterator>(begin());
14971497
}
14981498
template<value_type type>
14991499
value_iterator<type, iterator> cbegin() const {
15001500
return begin<type>();
15011501
}
15021502
template<value_type type>
15031503
std::reverse_iterator<value_iterator<type, iterator>> rbegin() const {
1504-
return std::reverse_iterator<value_iterator<type, iterator>>{ end<type>() };
1504+
return std::reverse_iterator<value_iterator<type, iterator>>(end<type>());
15051505
}
15061506
template<value_type type>
15071507
std::reverse_iterator<value_iterator<type, iterator>> crbegin() const {
@@ -1511,15 +1511,15 @@ namespace po {
15111511
template<value_type type>
15121512
value_iterator<type, iterator> end() const {
15131513
assert_iterator_type<type>();
1514-
return value_iterator<type, iterator>{ end() };
1514+
return value_iterator<type, iterator>(end());
15151515
}
15161516
template<value_type type>
15171517
value_iterator<type, iterator> cend() const {
15181518
return end<type>();
15191519
}
15201520
template<value_type type>
15211521
std::reverse_iterator<value_iterator<type, iterator>> rend() const {
1522-
return std::reverse_iterator<value_iterator<type, iterator>>{ begin<type>() };
1522+
return std::reverse_iterator<value_iterator<type, iterator>>(begin<type>());
15231523
}
15241524
template<value_type type>
15251525
std::reverse_iterator<value_iterator<type, iterator>> crend() const {
@@ -2005,7 +2005,7 @@ namespace po {
20052005
<< error()
20062006
<< "unexpected character \'" << argv[i][j] << "\'"
20072007
<< ignoring(argv[i])
2008-
<< suggest(std::string{ &argv[i][0], &argv[i][j] } + "=" + std::string{ &argv[i][j] }) << '\n';
2008+
<< suggest(std::string(&argv[i][0], &argv[i][j]) + "=" + &argv[i][j]) << '\n';
20092009
return false;
20102010
}
20112011
return parse_argument(option, std::move(expression), argument);
@@ -2093,7 +2093,7 @@ namespace po {
20932093
*m_output_destination << '\n';
20942094
}
20952095
} else {
2096-
const auto opt = m_options.find(std::string{ first, last });
2096+
const auto opt = m_options.find(std::string(first, last));
20972097
if(opt == m_options.end()) {
20982098
good = false;
20992099
if(is_verbose()) {
@@ -2192,7 +2192,7 @@ namespace po {
21922192

21932193
public:
21942194
option& operator[](std::string const& designator) {
2195-
return operator_brackets_helper(std::string{ designator });
2195+
return operator_brackets_helper(std::string(designator));
21962196
}
21972197
option& operator[](std::string&& designator) {
21982198
return operator_brackets_helper(std::move(designator));
@@ -2250,26 +2250,26 @@ namespace po {
22502250
auto& opt = **iter;
22512251
if(opt.first.empty())
22522252
continue;
2253-
stream << repeat{ left_padding, ' ' };
2253+
stream << repeat(left_padding, ' ');
22542254
const char abbreviation = opt.second.get_abbreviation();
22552255
const bool verbose = opt.first.size() > 1;
22562256
if(abbreviation)
22572257
stream << white << '-' << abbreviation;
22582258
else
2259-
stream << repeat{ abbreviation_width, ' ' };
2259+
stream << repeat(abbreviation_width, ' ');
22602260
if(abbreviation && verbose)
22612261
stream << ',' << ' ';
22622262
else
2263-
stream << repeat{ separator_width, ' ' };
2263+
stream << repeat(separator_width, ' ');
22642264
if(verbose) {
22652265
stream << white << '-' << '-' << opt.first;
22662266
const int rem = static_cast<int>(verbose_width) - 2 - static_cast<int>(opt.first.size());
22672267
if(rem >= 0)
2268-
stream << repeat{ static_cast<std::size_t>(rem) + mid_padding, ' ' };
2268+
stream << repeat(static_cast<std::size_t>(rem) + mid_padding, ' ');
22692269
else
2270-
stream << '\n' << repeat{ description_start, ' ' };
2270+
stream << '\n' << repeat(description_start, ' ');
22712271
} else {
2272-
stream << repeat{ verbose_width + mid_padding, ' ' };
2272+
stream << repeat(verbose_width + mid_padding, ' ');
22732273
}
22742274
std::size_t carriage = description_start;
22752275
std::string const& descr = opt.second.get_description();
@@ -2287,7 +2287,7 @@ namespace po {
22872287
}
22882288
if(descr[i] == '\n' || last) {
22892289
carriage = description_start + paragraph_indenture;
2290-
stream << '\n' << repeat{ carriage, ' ' };
2290+
stream << '\n' << repeat(carriage, ' ');
22912291
if(std::isblank(descr[i + 1]))
22922292
++i;
22932293
} else {

test/arg_provider.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public:
2121
}
2222
template<typename... args_t>
2323
explicit arg_provider(args_t&&... args)
24-
: arg_provider{ po::make_index_sequence<sizeof...(args_t)>{}, std::forward<args_t>(args)... } {
24+
: arg_provider(po::make_index_sequence<sizeof...(args_t)>{}, std::forward<args_t>(args)...) {
2525
}
2626
};
2727

0 commit comments

Comments
 (0)