Date: Wed, 20 Jul 2022 12:32:27 +0300
Couldn't you use std::conditional for the same purpose?
https://en.cppreference.com/w/cpp/types/conditional
On Wed, Jul 20, 2022 at 12:28 PM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> Right now with C++20 we can use the preprocessor to select different
> types, as follows:
>
> #define USE_DEBUGGING_CONTAINERS
>
> #ifdef USE_DEBUGGING_CONTAINERS
> using __gnu_debug::vector;
> #else
> using std::vector;
> #endif
>
> However it would be nice if we could use the ternary operator with
> types in a few different contexts, for example:
>
> bool constexpr use_debugging_containers = true;
>
> using (use_debugging_containers ? __gnu_debug::vector :
> std::vector );
>
> typedef (use_debugging_containers ? __gnu_debug::vector<int>
> : std::vector<int> ) IntVec;
>
> The closest thing we have to this at the moment is a lot more complicated:
>
> bool constexpr use_debugging_containers = true;
>
> namespace Containers {
>
> template<bool x>
> class detail {
> template<typename... Args>
> using vector = std::vector<Args...>;
> };
>
> template<>
> class detail<true> {
> template<typename... Args>
> using vector = __gnu_debug::vector<Args...>;
> };
>
> template<typename... Args>
> using vector =
> detail<use_debugging_containers>::vector<Args...>;
> }
>
> using namespace Containers;
>
> int main(void)
> {
> vector<double> vec;
> }
>
> Also I propose that the ternaries can be nested:
>
> typedef ( number > 65535u ? uint32_t : ( number > 255u ?
> uint16_t : uint8_t ) ) IntT;
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
https://en.cppreference.com/w/cpp/types/conditional
On Wed, Jul 20, 2022 at 12:28 PM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> Right now with C++20 we can use the preprocessor to select different
> types, as follows:
>
> #define USE_DEBUGGING_CONTAINERS
>
> #ifdef USE_DEBUGGING_CONTAINERS
> using __gnu_debug::vector;
> #else
> using std::vector;
> #endif
>
> However it would be nice if we could use the ternary operator with
> types in a few different contexts, for example:
>
> bool constexpr use_debugging_containers = true;
>
> using (use_debugging_containers ? __gnu_debug::vector :
> std::vector );
>
> typedef (use_debugging_containers ? __gnu_debug::vector<int>
> : std::vector<int> ) IntVec;
>
> The closest thing we have to this at the moment is a lot more complicated:
>
> bool constexpr use_debugging_containers = true;
>
> namespace Containers {
>
> template<bool x>
> class detail {
> template<typename... Args>
> using vector = std::vector<Args...>;
> };
>
> template<>
> class detail<true> {
> template<typename... Args>
> using vector = __gnu_debug::vector<Args...>;
> };
>
> template<typename... Args>
> using vector =
> detail<use_debugging_containers>::vector<Args...>;
> }
>
> using namespace Containers;
>
> int main(void)
> {
> vector<double> vec;
> }
>
> Also I propose that the ternaries can be nested:
>
> typedef ( number > 65535u ? uint32_t : ( number > 255u ?
> uint16_t : uint8_t ) ) IntT;
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2022-07-20 09:32:43