如何(以及谁可以)实现C ++委员会定义的标准库功能? [英] How to (and who can) implement the standard library features defined by the C++ committee?

查看:45
本文介绍了如何(以及谁可以)实现C ++委员会定义的标准库功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当C ++委员会发布新功能并将成为该语言的下一个标准中的标准库的一部分时,他们还将发布一些源代码或有关如何实现该功能的某种指导?

When the C++ committee publish a new feature that will be part of the standard library in the next standard of the language, they also release some source code or some kind of guidance on how to implement that feature?

让我们以 unique_ptr 为例.语言委员会只是为该类模板定义一个接口,然后让编译器供应商根据需要实现它?标准库功能的实现过程到底发生了什么.

Let's take unique_ptr as an example. The language committee just defines an interface for that class template and let the compiler vendor implement it as it wants? How exactly this process of implementation of the standard library features occurs.

任何人都可以为尚不支持该平台的平台实现部分标准库吗?假设我想实现C ++标准库的一些很酷的功能,以便在微控制器环境中使用它.我该怎么办?我应该在哪里寻找信息?如果我决定将项目开源,可以这样做吗?我是否需要严格遵循标准所说的内容,或者我可以编写不合规的版本?

Can anyone implement parts of the standard library for a platform that doesn't have support for it yet? Let say I would like to implement some cool features of the C++ standard library to use it on a microcontroller environment. How could I do that? Where should I look for information? If I decide to turn my project open source, can I do that? Will I need to follow exactly what the standard say or I can write a non-compliant version?

推荐答案

通常

  • 每个新库功能都通过提案.

如果该提案被提交给C ++委员会的库演化工作组,它将经历一系列的迭代(据我所知,这是一个艰难的境地").

If the proposal makes it to the C++ committee's Library Evolution Working Group, it goes through a series of iterations (a "tough ground" as I am aware).

它按照此处

如果需要(TS)技术规范(自C ++ 11起),就可以在那里进行烘烤.例如, #include< filesystem> 在C ++ 17之前位于 Filesystem TS 中.

Should it require a (TS) Technical Specification (since C++11), it goes there to be baked. Take for example, the #include <filesystem> was in a Filesystem TS prior to C++17.

我相信委员会喜欢的一件事是实施经验.

One thing I believe the committee likes, is an implementation experience.

更多信息,请参见 ISOCpp网站

关于实施:

  • 有很多库功能"不能完全作为库来实现.他们需要编译器支持.在这种情况下,编译器提供了您可以依赖的本能".例如,clang为某些type_trait提供内在

大多数库功能都有一些实现经验,大部分来自 Boost库.

Most library features have some implementation experience, mostly from the Boost libraries.

您实际上可以查看编译器随附的默认标准库的源代码:

You could actually look into the source code for the default standard library that ships with your compiler:

  • libc++ for Clang
  • libstdc++ for GCC

可悲的是,大多数实现都使用大量的下划线.主要是因为它们保留供标准库"使用.

Sadly most of the implementations use a whole bunch of underscores. Mostly because they are reserved for use by the "Standard Library".

任何人都可以为尚不支持该平台的平台实现部分标准库吗?

Can anyone implement parts of the standard library for a platform that doesn't have support for it yet?

是的,到目前为止,您可以编译器支持该平台,并且该平台或操作系统提供了可用的API.例如. std :: cout std :: ifstream 的元素等等,需要平台特定的支持.

Yes, you can, so far your compiler supports that platform, and the platform or Operating System provides usable API. For example. std::cout, elements of std::ifstream, and so much more requires platform specific support.

让我说我想实现C ++标准库的一些很酷的功能,以便在微控制器环境中使用它.我该怎么办?

Let say I would like to implement some cool features of the C++ standard library to use it on a microcontroller environment. How could I do that?

您可以调查其他人的代码,然后从那里开始.我们向巨人学习.一些开源示例:

You can look into the code of others and start from there. We learn from giants. Some Open Source Examples:

我该怎么做?我应该在哪里寻找信息?

How could I do that? Where should I look for information?

  • 您可以查看将功能引入C ++库的文章.例如, std :: optional 具有独立的实现此处在提案阶段用作参考实施.

    • You could check the paper that introduced the feature into the C++ library. For example, std::optional has a stand-alone implementation here which was used as a reference implementation during the proposal stages.

      您可以检查标准库,并进行艰苦的研究.:-)

      You could check the standard library, and do a laborious study. :-)

      我是否需要严格按照标准所说,否则我可以编写不符合规定的版本?

      Will I need to follow exactly what the standard say or I can write a non-compliant version?

      没有强制遵循C ++标准库指定的内容.那将是您的自己的"库.

      There's is no compulsion to follow what the C++ standard library specifies. That would be your "own" library.

      这篇关于如何(以及谁可以)实现C ++委员会定义的标准库功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆