cisst-saw
Loading...
Searching...
No Matches
cmnRequiresDeepCopy.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5 Author(s): Anton Deguet
6 Created on: 2009-11-17
7
8 (C) Copyright 2009-2021 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17
18*/
19
20
26#pragma once
27
28#ifndef _cmnRequiresDeepCopy_h
29#define _cmnRequiresDeepCopy_h
30
33
38template <class _elementType>
40 return true;
41}
42
46template <> inline bool cmnRequiresDeepCopy<float>(void) { return false; }
47template <> inline bool cmnRequiresDeepCopy<double>(void) { return false; }
48template <> inline bool cmnRequiresDeepCopy<long double>(void) { return false; }
49template <> inline bool cmnRequiresDeepCopy<bool>(void) { return false; }
50template <> inline bool cmnRequiresDeepCopy<char>(void) { return false; }
51template <> inline bool cmnRequiresDeepCopy<unsigned char>(void) { return false; }
52template <> inline bool cmnRequiresDeepCopy<short>(void) { return false; }
53template <> inline bool cmnRequiresDeepCopy<unsigned short>(void) { return false; }
54template <> inline bool cmnRequiresDeepCopy<int>(void) { return false; }
55template <> inline bool cmnRequiresDeepCopy<unsigned int>(void) { return false; }
56template <> inline bool cmnRequiresDeepCopy<long long int>(void) { return false; }
57template <> inline bool cmnRequiresDeepCopy<unsigned long long int>(void) { return false; }
59
60#include <string.h> // for memcpy
61template <class _elementType>
62void cmnMemcpy(_elementType * destination, const _elementType * source,
63 const size_t size) {
64 memcpy(reinterpret_cast<void *>(destination), reinterpret_cast<const void *>(source), size);
65}
66
67#include <string> // for template specialization
68template <> inline void cmnMemcpy<std::string>(std::string *, const std::string *, size_t) {
69 cmnThrow("cmnMemcpy should not be called with std::string");
70}
71
72#endif // _cmnRequiresDeepCopy_h
Portability across compilers and operating systems tools.
void cmnMemcpy< std::string >(std::string *, const std::string *, size_t)
Definition cmnRequiresDeepCopy.h:68
bool cmnRequiresDeepCopy(void)
Definition cmnRequiresDeepCopy.h:39
void cmnMemcpy(_elementType *destination, const _elementType *source, const size_t size)
Definition cmnRequiresDeepCopy.h:62
Declaration of the template function cmnThrow.
void cmnThrow(const _exceptionType &except, cmnLogLevel lod=CMN_LOG_LEVEL_INIT_ERROR)
Definition cmnThrow.h:76
size_type size(void) const
Definition vctDynamicConstMatrixBase.h:228