Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

Boost.Hana: boost::hana::literals Namespace Reference

Boost , ,

Boost.Hana  1.0.1
Your standard library for metaprogramming
Пространство имен, содержащее определяемые пользователем буквы C++14, предоставленные Ханой.Больше...

Functions

template<char... c>
constexpr auto operator""_c ()
 Creates a hana::integral_constant from a literal. More...
 
template<typename CharT , CharT... s>
constexpr auto operator""_s ()
 Creates a compile-time string from a string literal. More...
 

Detailed Description

Пространство имен, содержащее определяемые пользователем буквы C++14, предоставленные Ханой.

Function Documentation

template<char... c>
constexpr auto boost::hana::literals::operator""_c ( )

Создает<hana::integral_constant>из букв.

Буквальный анализируется во время компиляции, и результат возвращается в виде<llong<...>>.

Note
We use llong<...> instead of ullong<...> because using an unsigned type leads to unexpected behavior when doing stuff like -1_c. If we used an unsigned type, -1_c would be something like ullong<-1> which is actually ullong<something huge>.

Example

using namespace hana::literals; // contains the _c suffix
BOOST_HANA_CONSTANT_CHECK(1234_c == hana::llong_c<1234>);
BOOST_HANA_CONSTANT_CHECK(-1234_c == hana::llong_c<-1234>);
BOOST_HANA_CONSTANT_CHECK(1_c + (3_c * 4_c) == hana::llong_c<1 + (3 * 4)>);

СсылкиУсиление::hana::applyиповышение::hana::value.

template<typename CharT , CharT... s>
constexpr auto boost::hana::literals::operator""_s ( )

Создает строку времени компиляции из строки буквально.

Буквальная строка анализируется во время компиляции, и результат возвращается как<hana::string>. Эта функция является расширением, которое отключено по умолчанию; см. Ниже для деталей.

Note
Only narrow string literals are supported right now; support for fancier types of string literals like wide or UTF-XX might be added in the future if there is a demand for it. See this issue if you need this.
Warning
This user-defined literal is an extension which requires a special string literal operator that is not part of the standard yet. That operator is supported by both Clang and GCC, and several proposals were made for it to enter C++17. However, since it is not standard, it is disabled by default and defining the BOOST_HANA_CONFIG_ENABLE_STRING_UDL config macro is required to get this operator. Hence, if you want to stay safe, just use the BOOST_HANA_STRING macro instead. If you want to be fast and furious (I do), define BOOST_HANA_CONFIG_ENABLE_STRING_UDL.

Example

// Copyright Louis Dionne 2013-2016
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
namespace hana = boost::hana;
using namespace hana::literals;
// By default, this is disabled
#ifdef BOOST_HANA_CONFIG_ENABLE_STRING_UDL
constexpr auto str = "Hello world!"_s;
BOOST_HANA_CONSTANT_CHECK(str == hana::string_c<'H', 'e', 'l', 'l', 'o', ' ',
'w', 'o', 'r', 'l', 'd', '!'>);
BOOST_HANA_CONSTANT_CHECK(hana::is_a<hana::string_tag>(str));
BOOST_HANA_CONSTANT_CHECK(hana::length(str) == hana::size_c<12>);
#endif
int main() { }

Ссылкиboost::hana::apply,boost::hana::find,boost::hana::if_,boost::hana::lexicographical_compare, иboost::hana::value.

Статья Boost.Hana: boost::hana::literals Namespace Reference раздела может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-19 21:00:24/0.0083169937133789/1