[RFC,v1,03/23] libcamera: base: Add file for C++20 polyfills
diff mbox series

Message ID 20250606164156.1442682-4-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • libcamera: Add `MetadataList`
Related show

Commit Message

Barnabás Pőcze June 6, 2025, 4:41 p.m. UTC
Add `cxx20.h` that will contain (possibly limited) C++17 implementations
of some C++20 standard library features.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 include/libcamera/base/details/cxx20.h | 12 ++++++++++++
 include/libcamera/base/meson.build     |  1 +
 2 files changed, 13 insertions(+)
 create mode 100644 include/libcamera/base/details/cxx20.h

Comments

Jacopo Mondi June 10, 2025, 4:08 p.m. UTC | #1
I was wondering where std::polyfill was then I realized what it means
:)

On Fri, Jun 06, 2025 at 06:41:36PM +0200, Barnabás Pőcze wrote:
> Add `cxx20.h` that will contain (possibly limited) C++17 implementations
> of some C++20 standard library features.
>
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  include/libcamera/base/details/cxx20.h | 12 ++++++++++++
>  include/libcamera/base/meson.build     |  1 +
>  2 files changed, 13 insertions(+)
>  create mode 100644 include/libcamera/base/details/cxx20.h
>
> diff --git a/include/libcamera/base/details/cxx20.h b/include/libcamera/base/details/cxx20.h

nit: do we need the 'details' subfolder or namespacing would be
enough ?

> new file mode 100644
> index 000000000..0d6173d1b
> --- /dev/null
> +++ b/include/libcamera/base/details/cxx20.h
> @@ -0,0 +1,12 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2025, Ideas on Board Oy
> + *
> + * C++20 polyfills
> + */
> +
> +#pragma once
> +
> +namespace libcamera::details::cxx20 {
> +
> +} /* namespace libcamera::details::cxx20 */
> diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build
> index f28ae4d42..9b93b89c3 100644
> --- a/include/libcamera/base/meson.build
> +++ b/include/libcamera/base/meson.build
> @@ -5,6 +5,7 @@ libcamera_base_include_dir = libcamera_include_dir / 'base'
>  libcamera_base_public_headers = files([
>      'bound_method.h',
>      'class.h',
> +    'details/cxx20.h',
>      'flags.h',
>      'object.h',
>      'shared_fd.h',
> --
> 2.49.0
>
Barnabás Pőcze June 23, 2025, 2:22 p.m. UTC | #2
Hi

2025. 06. 10. 18:08 keltezéssel, Jacopo Mondi írta:
> I was wondering where std::polyfill was then I realized what it means
> :)
> 
> On Fri, Jun 06, 2025 at 06:41:36PM +0200, Barnabás Pőcze wrote:
>> Add `cxx20.h` that will contain (possibly limited) C++17 implementations
>> of some C++20 standard library features.
>>
>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
>> ---
>>   include/libcamera/base/details/cxx20.h | 12 ++++++++++++
>>   include/libcamera/base/meson.build     |  1 +
>>   2 files changed, 13 insertions(+)
>>   create mode 100644 include/libcamera/base/details/cxx20.h
>>
>> diff --git a/include/libcamera/base/details/cxx20.h b/include/libcamera/base/details/cxx20.h
> 
> nit: do we need the 'details' subfolder or namespacing would be
> enough ?

Since this file only has internal things, my preference is to keep
them in a separate subdirectory. This is what other C++ projects
also do: e.g. boost, abseil, folly. Whether it's "detail", "details",
"internal", or else is debatable, but I think it makes sense to keep
them separate.


Regards,
Barnabás Pőcze


> 
>> new file mode 100644
>> index 000000000..0d6173d1b
>> --- /dev/null
>> +++ b/include/libcamera/base/details/cxx20.h
>> @@ -0,0 +1,12 @@
>> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
>> +/*
>> + * Copyright (C) 2025, Ideas on Board Oy
>> + *
>> + * C++20 polyfills
>> + */
>> +
>> +#pragma once
>> +
>> +namespace libcamera::details::cxx20 {
>> +
>> +} /* namespace libcamera::details::cxx20 */
>> diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build
>> index f28ae4d42..9b93b89c3 100644
>> --- a/include/libcamera/base/meson.build
>> +++ b/include/libcamera/base/meson.build
>> @@ -5,6 +5,7 @@ libcamera_base_include_dir = libcamera_include_dir / 'base'
>>   libcamera_base_public_headers = files([
>>       'bound_method.h',
>>       'class.h',
>> +    'details/cxx20.h',
>>       'flags.h',
>>       'object.h',
>>       'shared_fd.h',
>> --
>> 2.49.0
>>

Patch
diff mbox series

diff --git a/include/libcamera/base/details/cxx20.h b/include/libcamera/base/details/cxx20.h
new file mode 100644
index 000000000..0d6173d1b
--- /dev/null
+++ b/include/libcamera/base/details/cxx20.h
@@ -0,0 +1,12 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2025, Ideas on Board Oy
+ *
+ * C++20 polyfills
+ */
+
+#pragma once
+
+namespace libcamera::details::cxx20 {
+
+} /* namespace libcamera::details::cxx20 */
diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build
index f28ae4d42..9b93b89c3 100644
--- a/include/libcamera/base/meson.build
+++ b/include/libcamera/base/meson.build
@@ -5,6 +5,7 @@  libcamera_base_include_dir = libcamera_include_dir / 'base'
 libcamera_base_public_headers = files([
     'bound_method.h',
     'class.h',
+    'details/cxx20.h',
     'flags.h',
     'object.h',
     'shared_fd.h',