Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ahTypes.H File Reference

Type traits for primitive type detection and swap operations. More...

Go to the source code of this file.

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Macros

#define DECLARE_PRIMITIVE(T)
 Macro to declare a type as primitive.
 
#define DECLARE_SWAP(T)
 Macro to declare optimized swap for primitive type.
 

Functions

template<typename T >
bool Aleph::is_primitive_type ()
 Check if type T is a primitive C++ type.
 
template<>
bool Aleph::is_primitive_type< char > ()
 
template<>
bool Aleph::is_primitive_type< unsigned char > ()
 
template<>
bool Aleph::is_primitive_type< short > ()
 
template<>
bool Aleph::is_primitive_type< unsigned short > ()
 
template<>
bool Aleph::is_primitive_type< int > ()
 
template<>
bool Aleph::is_primitive_type< unsigned int > ()
 
template<>
bool Aleph::is_primitive_type< long long > ()
 
template<>
bool Aleph::is_primitive_type< unsigned long long > ()
 
template<>
bool Aleph::is_primitive_type< float > ()
 
template<>
bool Aleph::is_primitive_type< double > ()
 
template<>
bool Aleph::is_primitive_type< long double > ()
 
template<class T >
TAleph::swap (T &t1, T &t2)
 Generic swap using object's swap method.
 
template<>
char & swap< char > (char &t1, char &t2)
 

Detailed Description

Type traits for primitive type detection and swap operations.

This file provides compile-time type traits for detecting primitive C++ types and optimized swap operations for those types.

Features

  • is_primitive_type<T>(): Returns true for C++ primitives
  • swap<T>(): Optimized swap for primitive types

Supported Primitive Types

  • char, unsigned char
  • short, unsigned short
  • int, unsigned int
  • long, unsigned long
  • long long, unsigned long long
  • float, double, long double

Usage Example

int a = 5, b = 10;
Aleph::swap(a, b); // Uses optimized primitive swap
T & swap(T &t1, T &t2)
Generic swap using object's swap method.
Definition ahTypes.H:121
bool is_primitive_type< int >()
Definition ahTypes.H:103
DynList< T > maps(const C &c, Op op)
Classic map operation.
Author
Leandro Rabindranath León

Definition in file ahTypes.H.

Macro Definition Documentation

◆ DECLARE_PRIMITIVE

#define DECLARE_PRIMITIVE (   T)
Value:
template <> \
bool is_primitive_type <T> () \
{ \
return true; \
}

Macro to declare a type as primitive.

Creates template specialization of is_primitive_type for type T.

Parameters
TPrimitive type to declare

Definition at line 92 of file ahTypes.H.

◆ DECLARE_SWAP

#define DECLARE_SWAP (   T)
Value:
template <> T & swap <T> (T & t1, T & t2) \
{ \
T tmp = t1; \
t1 = t2; \
t2 = tmp; \
return t1;

Macro to declare optimized swap for primitive type.

Creates template specialization using temporary variable.

Parameters
TPrimitive type

Definition at line 133 of file ahTypes.H.

Function Documentation

◆ swap< char >()

template<>
char & swap< char > ( char &  t1,
char &  t2 
)

Definition at line 142 of file ahTypes.H.