Skip to content

Commit 61191b8

Browse files
committed
Rename use_facet to get_facet
1 parent 2787e1c commit 61191b8

24 files changed

+195
-196
lines changed

docs/howto_add_printable_types.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ http://www.boost.org/LICENSE_1_0.txt)
3636

3737
:join: <<quick_reference#join,join>>
3838
:Facet: <<strf_hpp#Facet,Facet>>
39-
:use_facet: <<strf_hpp#use_facet,use_facet>>
39+
:get_facet: <<strf_hpp#get_facet,get_facet>>
4040
:facets_pack: <<strf_hpp#facets_pack,facets_pack>>
4141
:tag: <<strf_hpp#tag,tag>>
4242

@@ -602,18 +602,18 @@ Then, instead of calling `get_complex_form()`,
602602

603603
[source,cpp,subs=normal]
604604
----
605-
complex_form form = strf::{use_facet}<complex_form_c, std::complex<FloatT>>(facets);
605+
complex_form form = strf::{get_facet}<complex_form_c, std::complex<FloatT>>(facets);
606606
----
607607

608-
`use_facet` is used to extract a facet object from a `{facets_pack}` object.
608+
`get_facet` is used to extract a facet object from a `{facets_pack}` object.
609609
The first template parameter is the facet category.
610610
The second is the usually printable type and it only has effect when there is
611611
any <<tutorial#constrained_facets,constrained facets>> of the given category
612612
in the the `{facets_pack}` object. The effect is that
613-
`{use_facet}` only returns the value inside a constrained facet when
613+
`{get_facet}` only returns the value inside a constrained facet when
614614
`Filter<Tag>::value` is `true` ,
615615
where `Filter` is the template parameter of the constrained facet, and `Tag`
616-
is the second template parameter used in `{use_facet}`
616+
is the second template parameter used in `{get_facet}`
617617
( which is `std::complex<FloatT>` in this case ).
618618

619619
This way, the complex form would be specified by passing `complex_form`
@@ -778,7 +778,7 @@ First, the one that doesn't:
778778
const auto coord2 = strf::fmt(coordinates.second).set_float_format(float_fmt);
779779
const auto write_coord1 = strf::make_printer<CharT>(pre, facets, coord1);
780780
const auto write_coord2 = strf::make_printer<CharT>(pre, facets, coord2);
781-
const auto charset = strf::use_facet<strf::charset_c<CharT>, representative>(facets);
781+
const auto charset = strf::get_facet<strf::charset_c<CharT>, representative>(facets);
782782
783783
return [charset, form, write_coord1, write_coord2] (strf::destination<CharT>& dst)
784784
{

docs/howto_override_printable_types.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ http://www.boost.org/LICENSE_1_0.txt)
77

88
:printable_overrider_c: <<strf_hpp#printable_overrider_c,printable_overrider_c>>
99
:make_printer: <<strf_hpp#make_printer,make_printer>>
10-
:use_facet: <<strf_hpp#use_facet,use_facet>>
10+
:get_facet: <<strf_hpp#get_facet,get_facet>>
1111
:pack: <<strf_hpp#pack,pack>>
1212
:set_alignment_format: <<strf_hpp#alignment_format_specifier,set_alignment_format>>
1313
:get_alignment_format: <<strf_hpp#alignment_format_specifier,get_alignment_format>>
@@ -140,7 +140,7 @@ constexpr auto italian_bool = strf::constrain<is_bool>(italian_bool_facet{});
140140
<1> `strf::{representative_of_printable}<__X__>`
141141
commonly aliases to `__X__`, and it does so for `bool`.
142142
However, is a good practice to use it (instead `__X__`), because it is
143-
what the library uses (__i.e.__ parameterizes `<<strf_hpp#use_facet,use_facet>>`
143+
what the library uses (__i.e.__ parameterizes `<<strf_hpp#get_facet,get_facet>>`
144144
with ) when "deciding" whether to apply a facet or not.
145145

146146
Now we are ready:

docs/ref_facets_pack.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ http://www.boost.org/LICENSE_1_0.txt)
88
:facets_pack: <<facets_pack,facets_pack>>
99
:constrained_fpe: <<constrained_fpe,constrained_fpe>>
1010

11-
:use_facet: <<use_facet,use_facet>>
11+
:get_facet: <<get_facet,get_facet>>
1212
:facet_category: <<facet_category,facet_category>>
1313
:facet_traits: <<facet_traits,facet_traits>>
1414
:FacetCategory: <<FacetCategory, FacetCategory>>
@@ -97,12 +97,12 @@ Return type:: `{facets_pack}<std::remove_cvref_t<T>>\...>`
9797
Return value:: A `{facets_pack}` object initialized with `std::forward<T>(args)\...`
9898
====
9999

100-
=== Function template `use_facet` [[use_facet]]
100+
=== Function template `get_facet` [[get_facet]]
101101
====
102102
[source,cpp]
103103
----
104104
template <typename FCat, typename Tag, typename ... T>
105-
constexpr decltype(auto) use_facet(const facets_pack<T...>& fp);
105+
constexpr decltype(auto) get_facet(const facets_pack<T...>& fp);
106106
----
107107
Effects:: If <<has_facet, `has_facet<FCat, Tag>(fp)`>> returns `true` then
108108
returns `<<do_get_facet,do_get_facet>><FCat, Tag>(fp)`, otherwise
@@ -114,7 +114,7 @@ Compile-time requirements:: `FCat` is a _{FacetCategory}_ type.
114114
=== Hypothetical function template `has_facet`
115115
NOTE: This function template does not exist in this library.
116116
It is only documented to help to explain the
117-
`{use_facet}` function template.
117+
`{get_facet}` function template.
118118
====
119119
[source,cpp]
120120
----
@@ -139,7 +139,7 @@ Compile-time requirements::
139139
=== Hypothetical function template `do_get_facet`
140140
NOTE: This function template is not part of the library.
141141
It is only documented to help to explain the
142-
`{use_facet}` function template
142+
`{get_facet}` function template
143143
====
144144
[source,cpp]
145145
----
@@ -164,7 +164,7 @@ class constrained_fpe;
164164
The class template `constrained_fpe` is designed to be used in
165165
`{facets_pack}`. `constrained_fpe<Filter, FPE>`
166166
holds a value of `FPE` that will only be returned by
167-
`{use_facet}<Category, Tag>` if `Filter<Tag>::value` is `true`.
167+
`{get_facet}<Category, Tag>` if `Filter<Tag>::value` is `true`.
168168
169169
Compile-time requirements::
170170
- `Filter` is a __{UnaryTypeTrait}__. For any type `T`, the expression

docs/ref_printable_types_requirements.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ http://www.boost.org/LICENSE_1_0.txt)
2424

2525
:constrain: <<constrain,constrain>>
2626
:constrained_fpe: <<constrained_fpe,constrained_fpe>>
27-
:use_facet: <<use_facet,use_facet>>
27+
:get_facet: <<get_facet,get_facet>>
2828
:tag: <<tag,tag>>
2929
:rank: <<rank,rank>>
3030
:join: <<join,join>>
@@ -94,7 +94,7 @@ situations ( for example, the objects created by `fmt` and `{join}` ).
9494
----
9595
T::representative
9696
----
97-
The type used as the template argument in `{use_facet}`.
97+
The type used as the template argument in `{get_facet}`.
9898
This means it is the type that is tested by the
9999
the __UnaryTypeTrait__ template argument passed to
100100
`{constrain}` or `{constrained_fpe}`.
@@ -273,7 +273,7 @@ If `{printable_def_of}<Arg>::<<PrintableDef_is_overridable,is_overridable>>::val
273273
`make_printer` returns
274274
[source,cpp,subs=normal]
275275
----
276-
{use_facet}< {printable_overrider_c}, {representative_of_printable}<Arg> > (facets)
276+
{get_facet}< {printable_overrider_c}, {representative_of_printable}<Arg> > (facets)
277277
.make_printer({tag}<CharT>{}, pre, facets, arg);
278278
----
279279

docs/tutorial.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ auto str2 = strf::to_string.with(my_facets) (/{asterisk} \... {asterisk}/);
263263

264264
The `facets_pack` class template is designed more similarly to `std::tuple` than to `std::locale`.
265265
It stores all the facets objects by value, and accessing one them (
266-
with the `<<strf_hpp#use_facet,strf::use_facet>>` function template ) is just as fast as
266+
with the `<<strf_hpp#get_facet,strf::get_facet>>` function template ) is just as fast as
267267
calling a trivial getter function.
268268

269269
Any value that can be passed to the `with` function, can also be passed to `pack`,

docs/why_not_std_locale.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ to as of `std::tuple`, holding its elements by value,
4545
in contrast to `std::locale` were they
4646
are managed through reference counting.
4747

48-
`strf::use_facet` is as fast as a typical getter: it
48+
`strf::get_facet` is as fast as a typical getter: it
4949
just returns the reference of the requested object, or,
5050
if it is not present, a default value,
51-
while `std::use_facet` probably needs
51+
while `std::get_facet` probably needs
5252
to perform some run-time processing.
5353

5454
There is no base class that facets in Strf need to derive from.

examples/extend_input_base64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ struct printable_def<xxx::base64_input>
267267
, const FPack& facets
268268
, const input_with_fmt& arg )
269269
{
270-
auto f = strf::use_facet<xxx::base64_facet_c, representative>(facets);
270+
auto f = strf::get_facet<xxx::base64_facet_c, representative>(facets);
271271
return xxx::base64_printer<CharT>{f, arg.value(), arg.indentation()};
272272
}
273273

@@ -278,7 +278,7 @@ struct printable_def<xxx::base64_input>
278278
, const FPack& facets
279279
, const input_with_fmt& arg )
280280
{
281-
auto f = strf::use_facet<xxx::base64_facet_c, representative>(facets);
281+
auto f = strf::get_facet<xxx::base64_facet_c, representative>(facets);
282282
xxx::base64_printer<CharT> printer{f, arg.value(), arg.indentation()};
283283
pre->add_size(printer.calculate_size());
284284
return printer;

examples/extend_input_ipv6.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ class ipv6_printer
111111
, const strf::value_and_format<T...>& arg )
112112
: addr_(arg.value())
113113
, alignment_fmt_(arg.get_alignment_format())
114-
, lettercase_(strf::use_facet<strf::lettercase_c, xxx::ipv6address>(facets))
114+
, lettercase_(strf::get_facet<strf::lettercase_c, xxx::ipv6address>(facets))
115115
, style_(arg.get_ipv6style())
116116
{
117-
auto encoding = use_facet<strf::charset_c<CharT>, xxx::ipv6address>(facets);
117+
auto encoding = get_facet<strf::charset_c<CharT>, xxx::ipv6address>(facets);
118118

119119
encode_fill_fn_ = encoding.encode_fill_func();
120120
init_and_premeasure_(pre, encoding);

examples/extend_input_std_complex_v2.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ struct printable_def<std::complex<FloatT>>
188188
const auto coord2 = strf::fmt(coordinates.second).set_float_format(float_fmt);
189189
const auto write_coord1 = strf::make_printer<CharT>(pre, facets, coord1);
190190
const auto write_coord2 = strf::make_printer<CharT>(pre, facets, coord2);
191-
const auto charset = strf::use_facet<strf::charset_c<CharT>, representative>(facets);
191+
const auto charset = strf::get_facet<strf::charset_c<CharT>, representative>(facets);
192192

193193
return [charset, form, write_coord1, write_coord2] (strf::destination<CharT>& dst)
194194
{
@@ -238,12 +238,12 @@ struct printable_def<std::complex<FloatT>>
238238
assert(form == complex_form::polar);
239239
using rt = representative;
240240
if (pre->has_remaining_width()) {
241-
auto wcalc = strf::use_facet<strf::width_calculator_c, rt>(facets);
241+
auto wcalc = strf::get_facet<strf::width_calculator_c, rt>(facets);
242242
pre->add_width(wcalc.char_width(strf::utf_t<char32_t>{}, anglechar));
243243
pre->add_width(1);
244244
}
245245
if (PreMeasurements::size_demanded) {
246-
auto encoding = strf::use_facet<strf::charset_c<CharT>, rt>(facets);
246+
auto encoding = strf::get_facet<strf::charset_c<CharT>, rt>(facets);
247247
pre->add_size(encoding.encoded_char_size(anglechar));
248248
pre->add_size(1);
249249
}

include/strf/detail/facets/numpunct.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ class has_punct
651651

652652
using has_numpunct_type = decltype
653653
( test_numpunct
654-
( use_facet< strf::numpunct_c<Base>, InputT >(fp())) );
654+
( get_facet< strf::numpunct_c<Base>, InputT >(fp())) );
655655

656656
public:
657657

include/strf/detail/printable_types/bool.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct printable_def<bool>
142142
{
143143
pre->add_width(static_cast<strf::width_t>(5 - x));
144144
pre->add_size(5 - (int)x);
145-
return detail::bool_printer<CharT>{x, strf::use_facet<strf::lettercase_c, bool>(fp)};
145+
return detail::bool_printer<CharT>{x, strf::get_facet<strf::lettercase_c, bool>(fp)};
146146
}
147147

148148
template <typename CharT, typename PreMeasurements, typename FPack, typename... T>
@@ -157,11 +157,11 @@ struct printable_def<bool>
157157
const int w = 5 - (int) value;
158158
const auto afmt = x.get_alignment_format();
159159
const auto fmt_width = afmt.width.round();
160-
const auto lcase = strf::use_facet<strf::lettercase_c, bool>(fp);
160+
const auto lcase = strf::get_facet<strf::lettercase_c, bool>(fp);
161161

162162
if (fmt_width > w) {
163163
const int fillcount = fmt_width - w;
164-
auto charset = strf::use_facet<charset_c<CharT>, bool>(fp);
164+
auto charset = strf::get_facet<charset_c<CharT>, bool>(fp);
165165

166166
pre->add_width(static_cast<strf::width_t>(fmt_width));
167167
pre->add_size(w + fillcount * charset.encoded_char_size(afmt.fill));

include/strf/detail/printable_types/char.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class fmt_char_printer
3939
, afmt_(arg.get_alignment_format())
4040
, ch_(static_cast<CharT>(arg.value()))
4141
{
42-
auto charset = use_facet_<strf::charset_c<CharT>>(facets);
43-
auto&& wcalc = use_facet_<strf::width_calculator_c>(facets);
42+
auto charset = get_facet_<strf::charset_c<CharT>>(facets);
43+
auto&& wcalc = get_facet_<strf::width_calculator_c>(facets);
4444
encode_fill_fn_ = charset.encode_fill_func();
4545
init_(pre, wcalc, charset);
4646
}
@@ -58,10 +58,10 @@ class fmt_char_printer
5858

5959
template <typename Category, typename FPack>
6060
static STRF_HD
61-
STRF_DECLTYPE_AUTO((strf::use_facet<Category, CharT>(std::declval<FPack>())))
62-
use_facet_(const FPack& fp)
61+
STRF_DECLTYPE_AUTO((strf::get_facet<Category, CharT>(std::declval<FPack>())))
62+
get_facet_(const FPack& fp)
6363
{
64-
return fp.template use_facet<Category, CharT>();
64+
return fp.template get_facet<Category, CharT>();
6565
}
6666

6767
template <typename PreMeasurements, typename WCalc, typename Charset>
@@ -170,8 +170,8 @@ class fmt_conv_char32_printer
170170
: count_(arg.scount())
171171
, ch_(arg.value())
172172
{
173-
auto charset = strf::use_facet<charset_c<DstCharT>, char32_t>(facets);
174-
auto&& wcalc = use_facet<strf::width_calculator_c, char32_t>(facets);
173+
auto charset = strf::get_facet<charset_c<DstCharT>, char32_t>(facets);
174+
auto&& wcalc = get_facet<strf::width_calculator_c, char32_t>(facets);
175175
auto char_width = wcalc.char_width(strf::utf_t<char32_t>{}, ch_);
176176
init_(pre, charset, arg.get_alignment_format(), char_width);
177177
}
@@ -298,8 +298,8 @@ struct char_printing
298298

299299
pre->add_size(1);
300300
if (pre->has_remaining_width()) {
301-
auto&& wcalc = use_facet<strf::width_calculator_c, DstCharT>(facets);
302-
auto charset = use_facet<strf::charset_c<DstCharT>, SrcCharT>(facets);
301+
auto&& wcalc = get_facet<strf::width_calculator_c, DstCharT>(facets);
302+
auto charset = get_facet<strf::charset_c<DstCharT>, SrcCharT>(facets);
303303
auto w = wcalc.char_width(charset, static_cast<DstCharT>(x));
304304
pre->add_width(w);
305305
}
@@ -359,12 +359,12 @@ struct printable_def<char32_t>
359359
, char32_t x ) noexcept
360360
-> strf::detail::conv_char32_printer<DstCharT>
361361
{
362-
auto encoding = strf::use_facet<charset_c<DstCharT>, char32_t>(facets);
362+
auto encoding = strf::get_facet<charset_c<DstCharT>, char32_t>(facets);
363363
STRF_MAYBE_UNUSED(encoding);
364364
auto encoded_char_size = encoding.encoded_char_size(x);
365365
pre->add_size(encoded_char_size);
366366
if (pre->has_remaining_width()) {
367-
auto&& wcalc = use_facet<strf::width_calculator_c, char32_t>(facets);
367+
auto&& wcalc = get_facet<strf::width_calculator_c, char32_t>(facets);
368368
pre->add_width(wcalc.char_width(strf::utf_t<char32_t>{}, x));
369369
}
370370
return strf::detail::conv_char32_printer<DstCharT>

include/strf/detail/printable_types/float.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,16 +2233,16 @@ class punct_double_printer
22332233
, const FPack& facets
22342234
, const detail::float_with_fmt
22352235
< FloatT, strf::float_format_specifier_full_dynamic, HasAlignment >& arg )
2236-
: lettercase_(strf::use_facet<strf::lettercase_c, FloatT>(facets))
2236+
: lettercase_(strf::get_facet<strf::lettercase_c, FloatT>(facets))
22372237
{
2238-
auto charset = use_facet<strf::charset_c<CharT>, FloatT>(facets);
2238+
auto charset = get_facet<strf::charset_c<CharT>, FloatT>(facets);
22392239
encode_fill_ = charset.encode_fill_func();
22402240
encode_char_ = charset.encode_char_func();
22412241

22422242
auto notation = arg.float_notation();
22432243
if (arg.get_float_format().punctuate) {
2244-
auto punct_dec = strf::use_facet<strf::numpunct_c<10>, FloatT>(facets);
2245-
auto punct_hex = strf::use_facet<strf::numpunct_c<16>, FloatT>(facets);
2244+
auto punct_dec = strf::get_facet<strf::numpunct_c<10>, FloatT>(facets);
2245+
auto punct_hex = strf::get_facet<strf::numpunct_c<16>, FloatT>(facets);
22462246
grouping_ = punct_dec.grouping();
22472247
thousands_sep_ = punct_dec.thousands_sep();
22482248
decimal_point_ = ( notation != strf::float_notation::hex
@@ -2287,9 +2287,9 @@ class punct_double_printer
22872287
( PreMeasurements* pre
22882288
, const FPack& facets
22892289
, const detail::float_with_fmt<FloatT, FloatFormatter, HasAlignment>& arg )
2290-
: lettercase_(strf::use_facet<strf::lettercase_c, FloatT>(facets))
2290+
: lettercase_(strf::get_facet<strf::lettercase_c, FloatT>(facets))
22912291
{
2292-
auto charset = use_facet<strf::charset_c<CharT>, FloatT>(facets);
2292+
auto charset = get_facet<strf::charset_c<CharT>, FloatT>(facets);
22932293
encode_fill_ = charset.encode_fill_func();
22942294
auto r = strf::detail::init_float_printer_data
22952295
( data_, arg.value(), grouping_, arg.get_float_format()
@@ -2590,7 +2590,7 @@ struct float_printing
25902590
( strf::tag<CharT>, PreMeasurements* pre, const FPack& fp, FloatT x ) noexcept
25912591
-> strf::detail::fast_double_printer<CharT>
25922592
{
2593-
const fast_double_printer<CharT> p(x, strf::use_facet<strf::lettercase_c, float>(fp));
2593+
const fast_double_printer<CharT> p(x, strf::get_facet<strf::lettercase_c, float>(fp));
25942594
if (pre->has_remaining_width() || PreMeasurements::size_demanded) {
25952595
const auto s = p.size();
25962596
pre->add_width(static_cast<std::int16_t>(s));

0 commit comments

Comments
 (0)