-
Notifications
You must be signed in to change notification settings - Fork 169
Concept: point #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sdebionne
wants to merge
1
commit into
boostorg:cxx20-concept
Choose a base branch
from
sdebionne:cxx20-concept-point
base: cxx20-concept
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Concept: point #787
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| // | ||
| // Copyright 2005-2007 Adobe Systems Incorporated | ||
| // Copyright 2026 Samuel Debionne | ||
| // | ||
| // Distributed under the Boost Software License, Version 1.0 | ||
| // See accompanying file LICENSE_1_0.txt or copy at | ||
|
|
@@ -8,9 +9,13 @@ | |
| #ifndef BOOST_GIL_CONCEPTS_POINT_HPP | ||
| #define BOOST_GIL_CONCEPTS_POINT_HPP | ||
|
|
||
| #include <boost/gil/concepts/basic.hpp> | ||
| #include <boost/gil/concepts/concept_check.hpp> | ||
| #include <boost/gil/detail/config.hpp> | ||
|
|
||
| #if !defined(BOOST_GIL_HAS_CONCEPTS) | ||
| # error C++ 20 standard required. | ||
| #endif | ||
|
|
||
| #include <concepts> | ||
| #include <cstddef> | ||
|
|
||
| #if defined(BOOST_CLANG) | ||
|
|
@@ -27,7 +32,7 @@ | |
| namespace boost { namespace gil { | ||
|
|
||
| // Forward declarations | ||
| template <typename T> | ||
| template <BOOST_GIL_CONSTRAINT(std::regular) T> | ||
| class point; | ||
|
|
||
| template <std::size_t K, typename T> | ||
|
|
@@ -58,33 +63,21 @@ T& axis_value(point<T>& p); | |
| /// \ingroup PointConcept | ||
| /// | ||
| template <typename P> | ||
| struct PointNDConcept | ||
| concept PointNDConcept = requires(P point, typename P::template axis<0>::coord_t ft, typename P::template axis<P::num_dimensions - 1>::coord_t lt) | ||
| { | ||
| void constraints() | ||
| { | ||
| gil_function_requires<Regular<P>>(); | ||
|
|
||
| using value_type = typename P::value_type; | ||
| ignore_unused_variable_warning(value_type{}); | ||
|
|
||
| static const std::size_t N = P::num_dimensions; | ||
| ignore_unused_variable_warning(N); | ||
| using FT = typename P::template axis<0>::coord_t; | ||
| using LT = typename P::template axis<N - 1>::coord_t; | ||
| FT ft = gil::axis_value<0>(point); | ||
| axis_value<0>(point) = ft; | ||
| LT lt = axis_value<N - 1>(point); | ||
| axis_value<N - 1>(point) = lt; | ||
|
|
||
| //value_type v=point[0]; | ||
| //ignore_unused_variable_warning(v); | ||
| } | ||
| P point; | ||
| typename P::value_type; | ||
| requires std::regular<typename P::value_type>; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better write with concept conjunctions? |
||
|
|
||
| P::num_dimensions; | ||
| ft = gil::axis_value<0>(point); | ||
| axis_value<0>(point) = ft; | ||
| lt = axis_value<P::num_dimensions - 1>(point); | ||
| axis_value<P::num_dimensions - 1>(point) = lt; | ||
| }; | ||
|
|
||
| /// \brief 2-dimensional point concept | ||
| /// \code | ||
| /// concept Point2DConcept<typename T> : PointNDConcept<T> | ||
| /// concept Point2DConcept<typename T> : PointNDConcept<T>N | ||
| /// { | ||
| /// where num_dimensions == 2; | ||
| /// where SameType<axis<0>::type, axis<1>::type>; | ||
|
|
@@ -100,16 +93,11 @@ struct PointNDConcept | |
| /// \ingroup PointConcept | ||
| /// | ||
| template <typename P> | ||
| struct Point2DConcept | ||
| concept Point2DConcept = PointNDConcept<P> && requires(P point) | ||
| { | ||
| void constraints() | ||
| { | ||
| gil_function_requires<PointNDConcept<P>>(); | ||
| static_assert(P::num_dimensions == 2, ""); | ||
| point.x = point.y; | ||
| point[0] = point[1]; | ||
| } | ||
| P point; | ||
| requires P::num_dimensions == 2; | ||
| point.x = point.y; | ||
| point[0] = point[1]; | ||
| }; | ||
|
|
||
| }} // namespace boost::gil | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // | ||
| // Copyright 2026 Samuel Debionne | ||
| // | ||
| // Distributed under the Boost Software License, Version 1.0 | ||
| // See accompanying file LICENSE_1_0.txt or copy at | ||
| // http://www.boost.org/LICENSE_1_0.txt | ||
| // | ||
| #ifndef BOOST_GIL_DETAIL_CONFIG_HPP | ||
| #define BOOST_GIL_DETAIL_CONFIG_HPP | ||
|
|
||
| #include <boost/config.hpp> | ||
|
|
||
| #if !defined(BOOST_NO_CXX20_HDR_CONCEPTS) && defined(__cpp_lib_concepts) | ||
| #define BOOST_GIL_HAS_CONCEPTS | ||
| #endif | ||
|
|
||
| #ifdef BOOST_GIL_HAS_CONCEPTS | ||
| #define BOOST_GIL_CONSTRAINT(C) C | ||
| #else | ||
| #define BOOST_GIL_CONSTRAINT(C) typename | ||
| #endif | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concept should be lower case?