The Battle for Wesnoth  1.19.7+dev
Public Types | Static Public Attributes | List of all members
utils::const_clone< D, S > Struct Template Reference

Helper struct to clone the constness of one type to another. More...

#include <const_clone.hpp>

Public Types

using type = std::conditional_t< is_source_const, const D, D >
 The destination type, possibly const qualified. More...
 
using reference = std::conditional_t< is_source_const, const D &, D & >
 A reference to the destination type, possibly const qualified. More...
 
using pointer = std::conditional_t< is_source_const, const D *, D * >
 A pointer to the destination type, possibly const qualified. More...
 

Static Public Attributes

static const bool is_source_const
 

Detailed Description

template<typename D, typename S>
struct utils::const_clone< D, S >

Helper struct to clone the constness of one type to another.

Warning
It seems *this in a const member function is not a const object, use this, which is a pointer to a const object.
Template Parameters
DThe destination type, it should have no cv-qualifier and not be a pointer or reference.
SThe source type, this type may be a pointer or reference and obviously is allowed to have a cv-qualifier, although volatile has no effect.

Definition at line 37 of file const_clone.hpp.

Member Typedef Documentation

◆ pointer

template<typename D , typename S >
using utils::const_clone< D, S >::pointer = std::conditional_t<is_source_const, const D*, D*>

A pointer to the destination type, possibly const qualified.

Definition at line 55 of file const_clone.hpp.

◆ reference

template<typename D , typename S >
using utils::const_clone< D, S >::reference = std::conditional_t<is_source_const, const D&, D&>

A reference to the destination type, possibly const qualified.

Definition at line 51 of file const_clone.hpp.

◆ type

template<typename D , typename S >
using utils::const_clone< D, S >::type = std::conditional_t<is_source_const, const D, D>

The destination type, possibly const qualified.

Definition at line 47 of file const_clone.hpp.

Member Data Documentation

◆ is_source_const

template<typename D , typename S >
const bool utils::const_clone< D, S >::is_source_const
static
Initial value:
=
std::is_const_v<
std::remove_pointer_t<
std::remove_reference_t<S>
>
>

Definition at line 39 of file const_clone.hpp.


The documentation for this struct was generated from the following file: