diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:07:58 +0200 |
| commit | 967be9e750221ab2ab783f95df79bb26d290a45e (patch) | |
| tree | 6802900a5e975f9f68b169f0f503f040056d6952 /tiger-compiler/lib/misc/select-const.hh | |
Diffstat (limited to 'tiger-compiler/lib/misc/select-const.hh')
| -rw-r--r-- | tiger-compiler/lib/misc/select-const.hh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tiger-compiler/lib/misc/select-const.hh b/tiger-compiler/lib/misc/select-const.hh new file mode 100644 index 0000000..23ea6d0 --- /dev/null +++ b/tiger-compiler/lib/misc/select-const.hh @@ -0,0 +1,42 @@ +/** + ** \file misc/select-const.hh + ** \brief Select between a non const or a const type. + */ + +#pragma once + +namespace misc +{ + /*------------------. + | const selectors. | + `------------------*/ + + /// Return \a T constified. + template <typename T> struct constify_traits + { + using type = const T; + }; + + /// Return \a T as is. + template <typename T> struct id_traits + { + using type = T; + }; + + /*------------------. + | select_iterator. | + `------------------*/ + + /// The iterator over a non const structure is plain iterator. + template <typename T> struct select_iterator + { + using type = typename T::iterator; + }; + + /// The iterator over a const structure is a const_iterator. + template <typename T> struct select_iterator<const T> + { + using type = typename T::const_iterator; + }; + +} //namespace misc |
