Simple device (fancy) pointer implementationTrying to find a good design for reading in values of different types from a fileUnique pointer implementationHeap implementation using pointerSimple shared pointerArray-like container for uints shorter than 8 bits (Rev 1)Alternate “weak” pointer implementationPreferred implementation of `Array<T>::operator=(const Array<T> & rhs)`C++ maybe pointer type implementationAttempt at Smart Pointer ImplementationC++: Smart Pointer Implementation

Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

How is this relation reflexive?

Can I make popcorn with any corn?

TGV timetables / schedules?

DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?

How to report a triplet of septets in NMR tabulation?

"You are your self first supporter", a more proper way to say it

Prevent a directory in /tmp from being deleted

How can I automatically replace [[ and ]] with the [LeftDoubleBracket] and [RightDoubleBracket] operators?

New order #4: World

I probably found a bug with the sudo apt install function

Do Phineas and Ferb ever actually get busted in real time?

Why CLRS example on residual networks does not follows its formula?

Book about a traveler who helps planets in need

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

Theorems that impeded progress

Shell script can be run only with sh command

Draw simple lines in Inkscape

Set-theoretical foundations of Mathematics with only bounded quantifiers

A function which translates a sentence to title-case

What would the Romans have called "sorcery"?

What is the command to reset a PC without deleting any files



Simple device (fancy) pointer implementation


Trying to find a good design for reading in values of different types from a fileUnique pointer implementationHeap implementation using pointerSimple shared pointerArray-like container for uints shorter than 8 bits (Rev 1)Alternate “weak” pointer implementationPreferred implementation of `Array<T>::operator=(const Array<T> & rhs)`C++ maybe pointer type implementationAttempt at Smart Pointer ImplementationC++: Smart Pointer Implementation






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2












$begingroup$


device_raw_ptr is a simple fancy pointer. It essentially wrap pointers to GPU memory. It's sole purpose is to separate out host pointers from device pointers, i.e. they should not be inter-convertible and must not be dereferenced. At the same time, they should be zero-cost (with respect to raw host pointers) and be maximally compatible with regular pointers.



Helper class:



template <class T>
struct equality_operators
/*
** The deriving class must implement the following:
** friend bool operator==(const T&, const T&);
*/

friend bool operator!=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs == rhs);
;

template <class T>
struct less_than_operators
/*
** The deriving class must implement the following:
** friend bool operator<(const T&, const T&);
*/

friend bool operator>(const T& lhs, const T& rhs) return rhs < lhs;
friend bool operator<=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs > rhs);
friend bool operator>=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs < rhs);
;

template <class T>
struct relational_operators : equality_operators<T>, less_than_operators<T> ;


device_raw_ptr implementation:



template <class T>
class device_raw_ptr : public relational_operators<T>
static_assert(std::is_standard_layout<T>::value, "T must satisfy StandardLayoutType");
public:
using element_type = std::remove_extent_t<T>;

constexpr device_raw_ptr() noexcept = default;
constexpr device_raw_ptr(std::nullptr_t) noexcept : ptr nullptr
constexpr device_raw_ptr(const device_raw_ptr& other) noexcept = default;
explicit device_raw_ptr(element_type* ptr_) noexcept : ptr ptr_
device_raw_ptr(device_raw_ptr&& other) noexcept : ptr other.ptr other.reset();

device_raw_ptr& operator=(const device_raw_ptr& other) noexcept
swap(device_raw_ptr(other), *this);
return *this;


device_raw_ptr& operator=(device_raw_ptr&& other) noexcept
swap(device_raw_ptr(other), *this);
return *this;


void reset() noexcept ptr = nullptr;
void reset(T* ptr_) noexcept ptr = ptr_;

element_type* get() noexcept return ptr; ;
const element_type* get() const noexcept return ptr;

friend void swap(device_raw_ptr& lhs, device_raw_ptr& rhs) noexcept
using std::swap;
std::swap(lhs.ptr, rhs.ptr);


explicit operator bool() const noexcept return static_cast<bool>(ptr);

device_raw_ptr& operator++() noexcept
++ptr;
return *this;


device_raw_ptr operator++(int) noexcept
device_raw_ptr tmp(*this);
ptr++;
return tmp;


device_raw_ptr& operator+=(std::ptrdiff_t offset) noexcept
ptr += offset;
return *this;


device_raw_ptr& operator-=(std::ptrdiff_t offset) noexcept
ptr -= offset;
return *this;


friend device_raw_ptr& operator+(device_raw_ptr lhs, std::ptrdiff_t offset) noexcept
lhs += offset;
return lhs;


friend device_raw_ptr& operator-(device_raw_ptr lhs, std::ptrdiff_t offset) noexcept
lhs -= offset;
return lhs;


/* required by relational_operators base class */
friend bool operator==(const device_raw_ptr& lhs, const device_raw_ptr& rhs) noexcept return lhs.ptr == rhs.ptr;
friend bool operator<(const device_raw_ptr& lhs, const device_raw_ptr& rhs) noexcept return lhs.ptr < rhs.ptr;

protected:
T *ptr;
;

template <class T, class U, class V>
std::basic_ostream<U, V>& operator<<(std::basic_ostream<U, V>& os, const device_raw_ptr<T>& other)
os << other.get() << " (device)";
return os;



I am also looking for suggestions on how to order different things inside a class.



Might it be better to initialize with nullptr instead of the default constructor. This breaks compatibility but I think it might be worth considering the compiler would mostly optimize the assignment if it's immediately overwritten.










share|improve this question









New contributor




Yashas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    I just noticed that I am passing rvalues to swap which accepts non-const lvalue as arguments. You can find it in the copy & move constructor.
    $endgroup$
    – Yashas
    5 hours ago

















2












$begingroup$


device_raw_ptr is a simple fancy pointer. It essentially wrap pointers to GPU memory. It's sole purpose is to separate out host pointers from device pointers, i.e. they should not be inter-convertible and must not be dereferenced. At the same time, they should be zero-cost (with respect to raw host pointers) and be maximally compatible with regular pointers.



Helper class:



template <class T>
struct equality_operators
/*
** The deriving class must implement the following:
** friend bool operator==(const T&, const T&);
*/

friend bool operator!=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs == rhs);
;

template <class T>
struct less_than_operators
/*
** The deriving class must implement the following:
** friend bool operator<(const T&, const T&);
*/

friend bool operator>(const T& lhs, const T& rhs) return rhs < lhs;
friend bool operator<=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs > rhs);
friend bool operator>=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs < rhs);
;

template <class T>
struct relational_operators : equality_operators<T>, less_than_operators<T> ;


device_raw_ptr implementation:



template <class T>
class device_raw_ptr : public relational_operators<T>
static_assert(std::is_standard_layout<T>::value, "T must satisfy StandardLayoutType");
public:
using element_type = std::remove_extent_t<T>;

constexpr device_raw_ptr() noexcept = default;
constexpr device_raw_ptr(std::nullptr_t) noexcept : ptr nullptr
constexpr device_raw_ptr(const device_raw_ptr& other) noexcept = default;
explicit device_raw_ptr(element_type* ptr_) noexcept : ptr ptr_
device_raw_ptr(device_raw_ptr&& other) noexcept : ptr other.ptr other.reset();

device_raw_ptr& operator=(const device_raw_ptr& other) noexcept
swap(device_raw_ptr(other), *this);
return *this;


device_raw_ptr& operator=(device_raw_ptr&& other) noexcept
swap(device_raw_ptr(other), *this);
return *this;


void reset() noexcept ptr = nullptr;
void reset(T* ptr_) noexcept ptr = ptr_;

element_type* get() noexcept return ptr; ;
const element_type* get() const noexcept return ptr;

friend void swap(device_raw_ptr& lhs, device_raw_ptr& rhs) noexcept
using std::swap;
std::swap(lhs.ptr, rhs.ptr);


explicit operator bool() const noexcept return static_cast<bool>(ptr);

device_raw_ptr& operator++() noexcept
++ptr;
return *this;


device_raw_ptr operator++(int) noexcept
device_raw_ptr tmp(*this);
ptr++;
return tmp;


device_raw_ptr& operator+=(std::ptrdiff_t offset) noexcept
ptr += offset;
return *this;


device_raw_ptr& operator-=(std::ptrdiff_t offset) noexcept
ptr -= offset;
return *this;


friend device_raw_ptr& operator+(device_raw_ptr lhs, std::ptrdiff_t offset) noexcept
lhs += offset;
return lhs;


friend device_raw_ptr& operator-(device_raw_ptr lhs, std::ptrdiff_t offset) noexcept
lhs -= offset;
return lhs;


/* required by relational_operators base class */
friend bool operator==(const device_raw_ptr& lhs, const device_raw_ptr& rhs) noexcept return lhs.ptr == rhs.ptr;
friend bool operator<(const device_raw_ptr& lhs, const device_raw_ptr& rhs) noexcept return lhs.ptr < rhs.ptr;

protected:
T *ptr;
;

template <class T, class U, class V>
std::basic_ostream<U, V>& operator<<(std::basic_ostream<U, V>& os, const device_raw_ptr<T>& other)
os << other.get() << " (device)";
return os;



I am also looking for suggestions on how to order different things inside a class.



Might it be better to initialize with nullptr instead of the default constructor. This breaks compatibility but I think it might be worth considering the compiler would mostly optimize the assignment if it's immediately overwritten.










share|improve this question









New contributor




Yashas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    I just noticed that I am passing rvalues to swap which accepts non-const lvalue as arguments. You can find it in the copy & move constructor.
    $endgroup$
    – Yashas
    5 hours ago













2












2








2





$begingroup$


device_raw_ptr is a simple fancy pointer. It essentially wrap pointers to GPU memory. It's sole purpose is to separate out host pointers from device pointers, i.e. they should not be inter-convertible and must not be dereferenced. At the same time, they should be zero-cost (with respect to raw host pointers) and be maximally compatible with regular pointers.



Helper class:



template <class T>
struct equality_operators
/*
** The deriving class must implement the following:
** friend bool operator==(const T&, const T&);
*/

friend bool operator!=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs == rhs);
;

template <class T>
struct less_than_operators
/*
** The deriving class must implement the following:
** friend bool operator<(const T&, const T&);
*/

friend bool operator>(const T& lhs, const T& rhs) return rhs < lhs;
friend bool operator<=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs > rhs);
friend bool operator>=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs < rhs);
;

template <class T>
struct relational_operators : equality_operators<T>, less_than_operators<T> ;


device_raw_ptr implementation:



template <class T>
class device_raw_ptr : public relational_operators<T>
static_assert(std::is_standard_layout<T>::value, "T must satisfy StandardLayoutType");
public:
using element_type = std::remove_extent_t<T>;

constexpr device_raw_ptr() noexcept = default;
constexpr device_raw_ptr(std::nullptr_t) noexcept : ptr nullptr
constexpr device_raw_ptr(const device_raw_ptr& other) noexcept = default;
explicit device_raw_ptr(element_type* ptr_) noexcept : ptr ptr_
device_raw_ptr(device_raw_ptr&& other) noexcept : ptr other.ptr other.reset();

device_raw_ptr& operator=(const device_raw_ptr& other) noexcept
swap(device_raw_ptr(other), *this);
return *this;


device_raw_ptr& operator=(device_raw_ptr&& other) noexcept
swap(device_raw_ptr(other), *this);
return *this;


void reset() noexcept ptr = nullptr;
void reset(T* ptr_) noexcept ptr = ptr_;

element_type* get() noexcept return ptr; ;
const element_type* get() const noexcept return ptr;

friend void swap(device_raw_ptr& lhs, device_raw_ptr& rhs) noexcept
using std::swap;
std::swap(lhs.ptr, rhs.ptr);


explicit operator bool() const noexcept return static_cast<bool>(ptr);

device_raw_ptr& operator++() noexcept
++ptr;
return *this;


device_raw_ptr operator++(int) noexcept
device_raw_ptr tmp(*this);
ptr++;
return tmp;


device_raw_ptr& operator+=(std::ptrdiff_t offset) noexcept
ptr += offset;
return *this;


device_raw_ptr& operator-=(std::ptrdiff_t offset) noexcept
ptr -= offset;
return *this;


friend device_raw_ptr& operator+(device_raw_ptr lhs, std::ptrdiff_t offset) noexcept
lhs += offset;
return lhs;


friend device_raw_ptr& operator-(device_raw_ptr lhs, std::ptrdiff_t offset) noexcept
lhs -= offset;
return lhs;


/* required by relational_operators base class */
friend bool operator==(const device_raw_ptr& lhs, const device_raw_ptr& rhs) noexcept return lhs.ptr == rhs.ptr;
friend bool operator<(const device_raw_ptr& lhs, const device_raw_ptr& rhs) noexcept return lhs.ptr < rhs.ptr;

protected:
T *ptr;
;

template <class T, class U, class V>
std::basic_ostream<U, V>& operator<<(std::basic_ostream<U, V>& os, const device_raw_ptr<T>& other)
os << other.get() << " (device)";
return os;



I am also looking for suggestions on how to order different things inside a class.



Might it be better to initialize with nullptr instead of the default constructor. This breaks compatibility but I think it might be worth considering the compiler would mostly optimize the assignment if it's immediately overwritten.










share|improve this question









New contributor




Yashas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




device_raw_ptr is a simple fancy pointer. It essentially wrap pointers to GPU memory. It's sole purpose is to separate out host pointers from device pointers, i.e. they should not be inter-convertible and must not be dereferenced. At the same time, they should be zero-cost (with respect to raw host pointers) and be maximally compatible with regular pointers.



Helper class:



template <class T>
struct equality_operators
/*
** The deriving class must implement the following:
** friend bool operator==(const T&, const T&);
*/

friend bool operator!=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs == rhs);
;

template <class T>
struct less_than_operators
/*
** The deriving class must implement the following:
** friend bool operator<(const T&, const T&);
*/

friend bool operator>(const T& lhs, const T& rhs) return rhs < lhs;
friend bool operator<=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs > rhs);
friend bool operator>=(const T& lhs, const T& rhs) return !static_cast<bool>(lhs < rhs);
;

template <class T>
struct relational_operators : equality_operators<T>, less_than_operators<T> ;


device_raw_ptr implementation:



template <class T>
class device_raw_ptr : public relational_operators<T>
static_assert(std::is_standard_layout<T>::value, "T must satisfy StandardLayoutType");
public:
using element_type = std::remove_extent_t<T>;

constexpr device_raw_ptr() noexcept = default;
constexpr device_raw_ptr(std::nullptr_t) noexcept : ptr nullptr
constexpr device_raw_ptr(const device_raw_ptr& other) noexcept = default;
explicit device_raw_ptr(element_type* ptr_) noexcept : ptr ptr_
device_raw_ptr(device_raw_ptr&& other) noexcept : ptr other.ptr other.reset();

device_raw_ptr& operator=(const device_raw_ptr& other) noexcept
swap(device_raw_ptr(other), *this);
return *this;


device_raw_ptr& operator=(device_raw_ptr&& other) noexcept
swap(device_raw_ptr(other), *this);
return *this;


void reset() noexcept ptr = nullptr;
void reset(T* ptr_) noexcept ptr = ptr_;

element_type* get() noexcept return ptr; ;
const element_type* get() const noexcept return ptr;

friend void swap(device_raw_ptr& lhs, device_raw_ptr& rhs) noexcept
using std::swap;
std::swap(lhs.ptr, rhs.ptr);


explicit operator bool() const noexcept return static_cast<bool>(ptr);

device_raw_ptr& operator++() noexcept
++ptr;
return *this;


device_raw_ptr operator++(int) noexcept
device_raw_ptr tmp(*this);
ptr++;
return tmp;


device_raw_ptr& operator+=(std::ptrdiff_t offset) noexcept
ptr += offset;
return *this;


device_raw_ptr& operator-=(std::ptrdiff_t offset) noexcept
ptr -= offset;
return *this;


friend device_raw_ptr& operator+(device_raw_ptr lhs, std::ptrdiff_t offset) noexcept
lhs += offset;
return lhs;


friend device_raw_ptr& operator-(device_raw_ptr lhs, std::ptrdiff_t offset) noexcept
lhs -= offset;
return lhs;


/* required by relational_operators base class */
friend bool operator==(const device_raw_ptr& lhs, const device_raw_ptr& rhs) noexcept return lhs.ptr == rhs.ptr;
friend bool operator<(const device_raw_ptr& lhs, const device_raw_ptr& rhs) noexcept return lhs.ptr < rhs.ptr;

protected:
T *ptr;
;

template <class T, class U, class V>
std::basic_ostream<U, V>& operator<<(std::basic_ostream<U, V>& os, const device_raw_ptr<T>& other)
os << other.get() << " (device)";
return os;



I am also looking for suggestions on how to order different things inside a class.



Might it be better to initialize with nullptr instead of the default constructor. This breaks compatibility but I think it might be worth considering the compiler would mostly optimize the assignment if it's immediately overwritten.







c++ c++11 pointers






share|improve this question









New contributor




Yashas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Yashas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 5 hours ago









esote

3,01411039




3,01411039






New contributor




Yashas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 6 hours ago









YashasYashas

1113




1113




New contributor




Yashas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Yashas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Yashas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • $begingroup$
    I just noticed that I am passing rvalues to swap which accepts non-const lvalue as arguments. You can find it in the copy & move constructor.
    $endgroup$
    – Yashas
    5 hours ago
















  • $begingroup$
    I just noticed that I am passing rvalues to swap which accepts non-const lvalue as arguments. You can find it in the copy & move constructor.
    $endgroup$
    – Yashas
    5 hours ago















$begingroup$
I just noticed that I am passing rvalues to swap which accepts non-const lvalue as arguments. You can find it in the copy & move constructor.
$endgroup$
– Yashas
5 hours ago




$begingroup$
I just noticed that I am passing rvalues to swap which accepts non-const lvalue as arguments. You can find it in the copy & move constructor.
$endgroup$
– Yashas
5 hours ago










2 Answers
2






active

oldest

votes


















1












$begingroup$

Helper classes



There is no need to use static_cast<bool> for your comparisons. The relational operators are already bool values. (If they are not, that is a problem with the definition of the operator for the type T.)



The standard <utility> header provides definitions for operator!= (from operator==) and operator>, operator<=, and operator>= (from operator<). There is no need for you to define those four operators if you have the other two (equality and less-than).



Why do you have the relational_operators struct at all? It shouldn't be necessary.



Implementation



The default constructor for device_raw_ptr leaves the ptr member uninitialized. Typically a class like this would initialize ptr to nullptr, and you wouldn't need the constructor that takes a std::nullptr_t object.



The copy assignment operator should just be ptr = other.ptr, since that is the only thing in your class. The way you have it is nonstandard behavior. You construct a temporary, then pass it as a non-const reference to swap. This is not supported as part of the language, although some compilers (MSVC) support it as an extension. You're constructing a temporary, doing a swap, then destroying the temporary (a noop in this case). Similarly, the move assignment operator can be simplified to not use the temporary (ptr = other.ptr; other.reset();, or use three statements with an assignment to a local to avoid problems if you move assign an object to itself).



operator bool does not need a static_cast. Perhaps an explicit ptr != nullptr check, although a pointer will implicitly convert to a bool.






share|improve this answer









$endgroup$












  • $begingroup$
    I thought using std::rel_ops is generally frowned upon. stackoverflow.com/questions/6225375/idiomatic-use-of-stdrel-ops suggests using boost:operators. I wrote my own version instead.
    $endgroup$
    – Yashas
    5 hours ago










  • $begingroup$
    The default constructor leaves ptr unitialized because that's how raw pointers behave (initialized with garbage?). But I am considering the option of initializing it to nullptr. The std::nullptr_t is a consequence of the aforementioned statement. I intended to have a constexpr constructor which sets ptr to nullptr.
    $endgroup$
    – Yashas
    5 hours ago










  • $begingroup$
    For the abuse of swap, I made started (codereview.stackexchange.com/questions/217019/…) using temporaries right after I posted the question. It was an attempt to reuse the constructors to perform move/copy but I think it was overkill for such a simple class.
    $endgroup$
    – Yashas
    5 hours ago











  • $begingroup$
    @Yashas std::rel_ops is there to avoid having duplicate definitions of those relational operators. If a class does not want some of them (as mentioned in your linked question), then it should define all of them, and = delete the ones it doesn't want to support. But its up to you to decide how to implement them.
    $endgroup$
    – 1201ProgramAlarm
    5 hours ago











  • $begingroup$
    @Yashas leaving raw pointer uninitialized is, generally, a bad idea. The cost of assigning a nullptr someplace where it isn't strictly necessary is outweighed by the predictability and consistent (mis)behavior the NULL value will give you.
    $endgroup$
    – 1201ProgramAlarm
    5 hours ago


















1












$begingroup$

  1. device_raw_ptr is extremely cheap to copy, so remove all hints of move-semantics and use of swap().


  2. Now you can remove the copy-constructor and copy-assignment, as there is no need to explicitly declare them. Especially making them user-defined must be avoided to keep them trivial.


  3. Kudos on trying to use the approved two-step for swap(). Though you get a failing grade anyway because you bungled it by using a qualified call in the second part. Hopefully, C++20 will abolish that nonsense by introducing customization point objects.


  4. Yes, you should pass your device_raw_ptr by value if you have the choice, as it is a tiny trivial type. Still, refrain from returning a reference to such a temporary.


  5. There is no reason operator-(device_raw_ptr, std::ptrdiff_t) should not be constexpr. Aside from your implementation for some reason delegating to operator-=, which is not. Same for operator+ which uses operator+=.


  6. Is there any reason you don't support subtracting a device_raw_ptr from another?


  7. I'm really puzzled why you make the only data-member protected instead of private.






share|improve this answer









$endgroup$













    Your Answer





    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "196"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    Yashas is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217019%2fsimple-device-fancy-pointer-implementation%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1












    $begingroup$

    Helper classes



    There is no need to use static_cast<bool> for your comparisons. The relational operators are already bool values. (If they are not, that is a problem with the definition of the operator for the type T.)



    The standard <utility> header provides definitions for operator!= (from operator==) and operator>, operator<=, and operator>= (from operator<). There is no need for you to define those four operators if you have the other two (equality and less-than).



    Why do you have the relational_operators struct at all? It shouldn't be necessary.



    Implementation



    The default constructor for device_raw_ptr leaves the ptr member uninitialized. Typically a class like this would initialize ptr to nullptr, and you wouldn't need the constructor that takes a std::nullptr_t object.



    The copy assignment operator should just be ptr = other.ptr, since that is the only thing in your class. The way you have it is nonstandard behavior. You construct a temporary, then pass it as a non-const reference to swap. This is not supported as part of the language, although some compilers (MSVC) support it as an extension. You're constructing a temporary, doing a swap, then destroying the temporary (a noop in this case). Similarly, the move assignment operator can be simplified to not use the temporary (ptr = other.ptr; other.reset();, or use three statements with an assignment to a local to avoid problems if you move assign an object to itself).



    operator bool does not need a static_cast. Perhaps an explicit ptr != nullptr check, although a pointer will implicitly convert to a bool.






    share|improve this answer









    $endgroup$












    • $begingroup$
      I thought using std::rel_ops is generally frowned upon. stackoverflow.com/questions/6225375/idiomatic-use-of-stdrel-ops suggests using boost:operators. I wrote my own version instead.
      $endgroup$
      – Yashas
      5 hours ago










    • $begingroup$
      The default constructor leaves ptr unitialized because that's how raw pointers behave (initialized with garbage?). But I am considering the option of initializing it to nullptr. The std::nullptr_t is a consequence of the aforementioned statement. I intended to have a constexpr constructor which sets ptr to nullptr.
      $endgroup$
      – Yashas
      5 hours ago










    • $begingroup$
      For the abuse of swap, I made started (codereview.stackexchange.com/questions/217019/…) using temporaries right after I posted the question. It was an attempt to reuse the constructors to perform move/copy but I think it was overkill for such a simple class.
      $endgroup$
      – Yashas
      5 hours ago











    • $begingroup$
      @Yashas std::rel_ops is there to avoid having duplicate definitions of those relational operators. If a class does not want some of them (as mentioned in your linked question), then it should define all of them, and = delete the ones it doesn't want to support. But its up to you to decide how to implement them.
      $endgroup$
      – 1201ProgramAlarm
      5 hours ago











    • $begingroup$
      @Yashas leaving raw pointer uninitialized is, generally, a bad idea. The cost of assigning a nullptr someplace where it isn't strictly necessary is outweighed by the predictability and consistent (mis)behavior the NULL value will give you.
      $endgroup$
      – 1201ProgramAlarm
      5 hours ago















    1












    $begingroup$

    Helper classes



    There is no need to use static_cast<bool> for your comparisons. The relational operators are already bool values. (If they are not, that is a problem with the definition of the operator for the type T.)



    The standard <utility> header provides definitions for operator!= (from operator==) and operator>, operator<=, and operator>= (from operator<). There is no need for you to define those four operators if you have the other two (equality and less-than).



    Why do you have the relational_operators struct at all? It shouldn't be necessary.



    Implementation



    The default constructor for device_raw_ptr leaves the ptr member uninitialized. Typically a class like this would initialize ptr to nullptr, and you wouldn't need the constructor that takes a std::nullptr_t object.



    The copy assignment operator should just be ptr = other.ptr, since that is the only thing in your class. The way you have it is nonstandard behavior. You construct a temporary, then pass it as a non-const reference to swap. This is not supported as part of the language, although some compilers (MSVC) support it as an extension. You're constructing a temporary, doing a swap, then destroying the temporary (a noop in this case). Similarly, the move assignment operator can be simplified to not use the temporary (ptr = other.ptr; other.reset();, or use three statements with an assignment to a local to avoid problems if you move assign an object to itself).



    operator bool does not need a static_cast. Perhaps an explicit ptr != nullptr check, although a pointer will implicitly convert to a bool.






    share|improve this answer









    $endgroup$












    • $begingroup$
      I thought using std::rel_ops is generally frowned upon. stackoverflow.com/questions/6225375/idiomatic-use-of-stdrel-ops suggests using boost:operators. I wrote my own version instead.
      $endgroup$
      – Yashas
      5 hours ago










    • $begingroup$
      The default constructor leaves ptr unitialized because that's how raw pointers behave (initialized with garbage?). But I am considering the option of initializing it to nullptr. The std::nullptr_t is a consequence of the aforementioned statement. I intended to have a constexpr constructor which sets ptr to nullptr.
      $endgroup$
      – Yashas
      5 hours ago










    • $begingroup$
      For the abuse of swap, I made started (codereview.stackexchange.com/questions/217019/…) using temporaries right after I posted the question. It was an attempt to reuse the constructors to perform move/copy but I think it was overkill for such a simple class.
      $endgroup$
      – Yashas
      5 hours ago











    • $begingroup$
      @Yashas std::rel_ops is there to avoid having duplicate definitions of those relational operators. If a class does not want some of them (as mentioned in your linked question), then it should define all of them, and = delete the ones it doesn't want to support. But its up to you to decide how to implement them.
      $endgroup$
      – 1201ProgramAlarm
      5 hours ago











    • $begingroup$
      @Yashas leaving raw pointer uninitialized is, generally, a bad idea. The cost of assigning a nullptr someplace where it isn't strictly necessary is outweighed by the predictability and consistent (mis)behavior the NULL value will give you.
      $endgroup$
      – 1201ProgramAlarm
      5 hours ago













    1












    1








    1





    $begingroup$

    Helper classes



    There is no need to use static_cast<bool> for your comparisons. The relational operators are already bool values. (If they are not, that is a problem with the definition of the operator for the type T.)



    The standard <utility> header provides definitions for operator!= (from operator==) and operator>, operator<=, and operator>= (from operator<). There is no need for you to define those four operators if you have the other two (equality and less-than).



    Why do you have the relational_operators struct at all? It shouldn't be necessary.



    Implementation



    The default constructor for device_raw_ptr leaves the ptr member uninitialized. Typically a class like this would initialize ptr to nullptr, and you wouldn't need the constructor that takes a std::nullptr_t object.



    The copy assignment operator should just be ptr = other.ptr, since that is the only thing in your class. The way you have it is nonstandard behavior. You construct a temporary, then pass it as a non-const reference to swap. This is not supported as part of the language, although some compilers (MSVC) support it as an extension. You're constructing a temporary, doing a swap, then destroying the temporary (a noop in this case). Similarly, the move assignment operator can be simplified to not use the temporary (ptr = other.ptr; other.reset();, or use three statements with an assignment to a local to avoid problems if you move assign an object to itself).



    operator bool does not need a static_cast. Perhaps an explicit ptr != nullptr check, although a pointer will implicitly convert to a bool.






    share|improve this answer









    $endgroup$



    Helper classes



    There is no need to use static_cast<bool> for your comparisons. The relational operators are already bool values. (If they are not, that is a problem with the definition of the operator for the type T.)



    The standard <utility> header provides definitions for operator!= (from operator==) and operator>, operator<=, and operator>= (from operator<). There is no need for you to define those four operators if you have the other two (equality and less-than).



    Why do you have the relational_operators struct at all? It shouldn't be necessary.



    Implementation



    The default constructor for device_raw_ptr leaves the ptr member uninitialized. Typically a class like this would initialize ptr to nullptr, and you wouldn't need the constructor that takes a std::nullptr_t object.



    The copy assignment operator should just be ptr = other.ptr, since that is the only thing in your class. The way you have it is nonstandard behavior. You construct a temporary, then pass it as a non-const reference to swap. This is not supported as part of the language, although some compilers (MSVC) support it as an extension. You're constructing a temporary, doing a swap, then destroying the temporary (a noop in this case). Similarly, the move assignment operator can be simplified to not use the temporary (ptr = other.ptr; other.reset();, or use three statements with an assignment to a local to avoid problems if you move assign an object to itself).



    operator bool does not need a static_cast. Perhaps an explicit ptr != nullptr check, although a pointer will implicitly convert to a bool.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 5 hours ago









    1201ProgramAlarm1201ProgramAlarm

    3,7032925




    3,7032925











    • $begingroup$
      I thought using std::rel_ops is generally frowned upon. stackoverflow.com/questions/6225375/idiomatic-use-of-stdrel-ops suggests using boost:operators. I wrote my own version instead.
      $endgroup$
      – Yashas
      5 hours ago










    • $begingroup$
      The default constructor leaves ptr unitialized because that's how raw pointers behave (initialized with garbage?). But I am considering the option of initializing it to nullptr. The std::nullptr_t is a consequence of the aforementioned statement. I intended to have a constexpr constructor which sets ptr to nullptr.
      $endgroup$
      – Yashas
      5 hours ago










    • $begingroup$
      For the abuse of swap, I made started (codereview.stackexchange.com/questions/217019/…) using temporaries right after I posted the question. It was an attempt to reuse the constructors to perform move/copy but I think it was overkill for such a simple class.
      $endgroup$
      – Yashas
      5 hours ago











    • $begingroup$
      @Yashas std::rel_ops is there to avoid having duplicate definitions of those relational operators. If a class does not want some of them (as mentioned in your linked question), then it should define all of them, and = delete the ones it doesn't want to support. But its up to you to decide how to implement them.
      $endgroup$
      – 1201ProgramAlarm
      5 hours ago











    • $begingroup$
      @Yashas leaving raw pointer uninitialized is, generally, a bad idea. The cost of assigning a nullptr someplace where it isn't strictly necessary is outweighed by the predictability and consistent (mis)behavior the NULL value will give you.
      $endgroup$
      – 1201ProgramAlarm
      5 hours ago
















    • $begingroup$
      I thought using std::rel_ops is generally frowned upon. stackoverflow.com/questions/6225375/idiomatic-use-of-stdrel-ops suggests using boost:operators. I wrote my own version instead.
      $endgroup$
      – Yashas
      5 hours ago










    • $begingroup$
      The default constructor leaves ptr unitialized because that's how raw pointers behave (initialized with garbage?). But I am considering the option of initializing it to nullptr. The std::nullptr_t is a consequence of the aforementioned statement. I intended to have a constexpr constructor which sets ptr to nullptr.
      $endgroup$
      – Yashas
      5 hours ago










    • $begingroup$
      For the abuse of swap, I made started (codereview.stackexchange.com/questions/217019/…) using temporaries right after I posted the question. It was an attempt to reuse the constructors to perform move/copy but I think it was overkill for such a simple class.
      $endgroup$
      – Yashas
      5 hours ago











    • $begingroup$
      @Yashas std::rel_ops is there to avoid having duplicate definitions of those relational operators. If a class does not want some of them (as mentioned in your linked question), then it should define all of them, and = delete the ones it doesn't want to support. But its up to you to decide how to implement them.
      $endgroup$
      – 1201ProgramAlarm
      5 hours ago











    • $begingroup$
      @Yashas leaving raw pointer uninitialized is, generally, a bad idea. The cost of assigning a nullptr someplace where it isn't strictly necessary is outweighed by the predictability and consistent (mis)behavior the NULL value will give you.
      $endgroup$
      – 1201ProgramAlarm
      5 hours ago















    $begingroup$
    I thought using std::rel_ops is generally frowned upon. stackoverflow.com/questions/6225375/idiomatic-use-of-stdrel-ops suggests using boost:operators. I wrote my own version instead.
    $endgroup$
    – Yashas
    5 hours ago




    $begingroup$
    I thought using std::rel_ops is generally frowned upon. stackoverflow.com/questions/6225375/idiomatic-use-of-stdrel-ops suggests using boost:operators. I wrote my own version instead.
    $endgroup$
    – Yashas
    5 hours ago












    $begingroup$
    The default constructor leaves ptr unitialized because that's how raw pointers behave (initialized with garbage?). But I am considering the option of initializing it to nullptr. The std::nullptr_t is a consequence of the aforementioned statement. I intended to have a constexpr constructor which sets ptr to nullptr.
    $endgroup$
    – Yashas
    5 hours ago




    $begingroup$
    The default constructor leaves ptr unitialized because that's how raw pointers behave (initialized with garbage?). But I am considering the option of initializing it to nullptr. The std::nullptr_t is a consequence of the aforementioned statement. I intended to have a constexpr constructor which sets ptr to nullptr.
    $endgroup$
    – Yashas
    5 hours ago












    $begingroup$
    For the abuse of swap, I made started (codereview.stackexchange.com/questions/217019/…) using temporaries right after I posted the question. It was an attempt to reuse the constructors to perform move/copy but I think it was overkill for such a simple class.
    $endgroup$
    – Yashas
    5 hours ago





    $begingroup$
    For the abuse of swap, I made started (codereview.stackexchange.com/questions/217019/…) using temporaries right after I posted the question. It was an attempt to reuse the constructors to perform move/copy but I think it was overkill for such a simple class.
    $endgroup$
    – Yashas
    5 hours ago













    $begingroup$
    @Yashas std::rel_ops is there to avoid having duplicate definitions of those relational operators. If a class does not want some of them (as mentioned in your linked question), then it should define all of them, and = delete the ones it doesn't want to support. But its up to you to decide how to implement them.
    $endgroup$
    – 1201ProgramAlarm
    5 hours ago





    $begingroup$
    @Yashas std::rel_ops is there to avoid having duplicate definitions of those relational operators. If a class does not want some of them (as mentioned in your linked question), then it should define all of them, and = delete the ones it doesn't want to support. But its up to you to decide how to implement them.
    $endgroup$
    – 1201ProgramAlarm
    5 hours ago













    $begingroup$
    @Yashas leaving raw pointer uninitialized is, generally, a bad idea. The cost of assigning a nullptr someplace where it isn't strictly necessary is outweighed by the predictability and consistent (mis)behavior the NULL value will give you.
    $endgroup$
    – 1201ProgramAlarm
    5 hours ago




    $begingroup$
    @Yashas leaving raw pointer uninitialized is, generally, a bad idea. The cost of assigning a nullptr someplace where it isn't strictly necessary is outweighed by the predictability and consistent (mis)behavior the NULL value will give you.
    $endgroup$
    – 1201ProgramAlarm
    5 hours ago













    1












    $begingroup$

    1. device_raw_ptr is extremely cheap to copy, so remove all hints of move-semantics and use of swap().


    2. Now you can remove the copy-constructor and copy-assignment, as there is no need to explicitly declare them. Especially making them user-defined must be avoided to keep them trivial.


    3. Kudos on trying to use the approved two-step for swap(). Though you get a failing grade anyway because you bungled it by using a qualified call in the second part. Hopefully, C++20 will abolish that nonsense by introducing customization point objects.


    4. Yes, you should pass your device_raw_ptr by value if you have the choice, as it is a tiny trivial type. Still, refrain from returning a reference to such a temporary.


    5. There is no reason operator-(device_raw_ptr, std::ptrdiff_t) should not be constexpr. Aside from your implementation for some reason delegating to operator-=, which is not. Same for operator+ which uses operator+=.


    6. Is there any reason you don't support subtracting a device_raw_ptr from another?


    7. I'm really puzzled why you make the only data-member protected instead of private.






    share|improve this answer









    $endgroup$

















      1












      $begingroup$

      1. device_raw_ptr is extremely cheap to copy, so remove all hints of move-semantics and use of swap().


      2. Now you can remove the copy-constructor and copy-assignment, as there is no need to explicitly declare them. Especially making them user-defined must be avoided to keep them trivial.


      3. Kudos on trying to use the approved two-step for swap(). Though you get a failing grade anyway because you bungled it by using a qualified call in the second part. Hopefully, C++20 will abolish that nonsense by introducing customization point objects.


      4. Yes, you should pass your device_raw_ptr by value if you have the choice, as it is a tiny trivial type. Still, refrain from returning a reference to such a temporary.


      5. There is no reason operator-(device_raw_ptr, std::ptrdiff_t) should not be constexpr. Aside from your implementation for some reason delegating to operator-=, which is not. Same for operator+ which uses operator+=.


      6. Is there any reason you don't support subtracting a device_raw_ptr from another?


      7. I'm really puzzled why you make the only data-member protected instead of private.






      share|improve this answer









      $endgroup$















        1












        1








        1





        $begingroup$

        1. device_raw_ptr is extremely cheap to copy, so remove all hints of move-semantics and use of swap().


        2. Now you can remove the copy-constructor and copy-assignment, as there is no need to explicitly declare them. Especially making them user-defined must be avoided to keep them trivial.


        3. Kudos on trying to use the approved two-step for swap(). Though you get a failing grade anyway because you bungled it by using a qualified call in the second part. Hopefully, C++20 will abolish that nonsense by introducing customization point objects.


        4. Yes, you should pass your device_raw_ptr by value if you have the choice, as it is a tiny trivial type. Still, refrain from returning a reference to such a temporary.


        5. There is no reason operator-(device_raw_ptr, std::ptrdiff_t) should not be constexpr. Aside from your implementation for some reason delegating to operator-=, which is not. Same for operator+ which uses operator+=.


        6. Is there any reason you don't support subtracting a device_raw_ptr from another?


        7. I'm really puzzled why you make the only data-member protected instead of private.






        share|improve this answer









        $endgroup$



        1. device_raw_ptr is extremely cheap to copy, so remove all hints of move-semantics and use of swap().


        2. Now you can remove the copy-constructor and copy-assignment, as there is no need to explicitly declare them. Especially making them user-defined must be avoided to keep them trivial.


        3. Kudos on trying to use the approved two-step for swap(). Though you get a failing grade anyway because you bungled it by using a qualified call in the second part. Hopefully, C++20 will abolish that nonsense by introducing customization point objects.


        4. Yes, you should pass your device_raw_ptr by value if you have the choice, as it is a tiny trivial type. Still, refrain from returning a reference to such a temporary.


        5. There is no reason operator-(device_raw_ptr, std::ptrdiff_t) should not be constexpr. Aside from your implementation for some reason delegating to operator-=, which is not. Same for operator+ which uses operator+=.


        6. Is there any reason you don't support subtracting a device_raw_ptr from another?


        7. I'm really puzzled why you make the only data-member protected instead of private.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        DeduplicatorDeduplicator

        11.8k1950




        11.8k1950




















            Yashas is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Yashas is a new contributor. Be nice, and check out our Code of Conduct.












            Yashas is a new contributor. Be nice, and check out our Code of Conduct.











            Yashas is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Code Review Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid …


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f217019%2fsimple-device-fancy-pointer-implementation%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Is it wise to focus on putting odd beats on left when playing double bass drums?What does the tie across other different notes mean?How to improve right hand picking/strumming technique for electric and acoustic guitar?How fast is the BPM should you start to use double bass pedal?Alternative or more advanced methods for counting rhythmsLost direction in practicing drumsIs there any way at all to tell if these measures are 6/4 vs. 3/2?Why is alberti bass so tiring?How does 'meter' differ from 'rhythm' in music?Rhythm question about piano sheet notationWhy is Bach's Cello Suite 1 written in 16th notes

            map list to bin numbersquantilization (if that is a word)Map efficiently over duplicates in listGenerating a list of cubefree numbersIs there an equivalent to MATLAB's linspace?Convert a list of hexadecimal numbers to decimalTaking one list Mod a second listlist of items and group of alternative itemsHow find numbers in this list of inequalities?Selecting list entries with a True False index list of similar lengthReplace element in array by checking condition in another listAttempting to fill a table with the number of elements in each bin and make a table with the elements in the bins?

            History of India Contents Prehistoric era (until c. 3300 BCE) Bronze Age – "First urbanisation" (c. 3300 – c. 1800 BCE) Climate change, de-urbanisation, and Indo-Aryan migrations (c.1800 – 1500 BCE) Iron Age - Vedic period (c. 1500 – c. 600 BCE) "Second urbanisation" (c. 600 – c. 200 BCE) Classical to early medieval periods (c. 200 BCE – c. 1200 CE) Late medieval period (c. 1200 – 1526 CE) Early modern period (c. 1526–1858 CE) Modern period and independence (after c. 1850 CE) Historiography See also References Further reading External links Navigation menureviewedee[update]The crisisThe Evolution and History of Human Populations in South Asia: Inter-disciplinary Studies in Archaeology, Biological Anthropology, Linguistics and GeneticsThe Ancient Indus: Urbanism, Economy, and Society"Indus River Valley Civilizations"The Ancient Indus: Urbanism, Economy, and Society"India before the British: The Mughal Empire and its Rivals, 1526–1857"Why Europe Grew Rich and Asia Did Not: Global Economic Divergence, 1600–1850Development Centre Studies The World Economy Historical Statistics: Historical StatisticsDeveloping cultures: case studiesEthnic Groups of South Asia and the Pacific: An Encyclopedia: An Encyclopedia"Indian Economy During British Rule""Economic Impact of the British Rule in India | Indian History"The Bone Readers: Science and Politics in Human Origins Research"Out of Africa: new hypotheses and evidence for the dispersal of Homo sapiens along the Indian Ocean rim"10.3109/0301446100363924920334598"Genetic and archaeological perspectives on the initial modern human colonization of southern Asia"2013PNAS..11010699M10.1073/pnas.1306043110369678523754394"Edakkal Caves|Places Around in Wayanad"Protecting megaliths to keep history alive The Hindu daily"Archaeologists rock solid behind Edakkal Cave"The Global Prehistory of Human Migration"Indus Valley 2,000 years older than thought"the original"Stepwells -Cosmology of Subterranean Architecture as seen in Adalaj"A History of Ancient and Early medieval India : from the Stone Age to the 12th century"Stone celts in Harappa"the original"Peoples and languages in pre-islamic Indus valley"the original"The Sindhi language"the originalThe Aryan chromosome"Fluvial landscapes of the Harappan Civilization"2012PNAS..109E1688G10.1073/pnas.1112743109338705422645375"Is River Ghaggar, Saraswati? Geochemical Constraints""An Ancient Civilization, Upended by Climate Change""Huge Ancient Civilization's Collapse Explained"2003GeoRL..30.1425S10.1029/2002GL0168222006QSRv...25.1283M10.1016/j.quascirev.2005.10.0122011QuInt.229..140M10.1016/j.quaint.2009.11.012Climate Change and the Course of Global History: A Rough JourneyA History of Ancient and Early Medieval India: From the Stone Age to the 12th CenturyA History of Ancient and Mediaeval India: From the Stone Age to the 12th CenturyAntennae SwordA History of IndiaA History of IndiaAn Introduction to Hinduism"India: The Late 2nd Millennium and the Reemergence of Urbanism"The Coinage of Ancient IndiaA Sanskrit reader: with vocabulary and notesPedigree: the origins of words from nature"Early Sanskritization. Origins and Development of the Kuru State"10.11588/ejvs.1995.4.823The Sanskrit epics, Part 2The City in South AsiaThe UpanishadsAn Introduction to HinduismReligions of the World, Second Edition: A Comprehensive Encyclopedia of Beliefs and PracticesA History of Ancient and Early Medieval India: From the Stone Age to the 12th CenturyEarly India: From the Origins to AD 1300Republics in ancient Indiapp. 83ff"Magadha Empire""Lumbini Development Trust: Restoring the Lumbini Garden"the originalThe great armies of antiquityarchived"The Achaemenid Persian Empire (550–330 B.C.)""East–West Orientation of Historical Empires"1076-156X"Dinner on the Grand Trunk Road"10.2307/32502263250226"Silappathikaram Tamil Literature"the originalManimekalai – English transliteration of Tamil originalIndian Temple Architecture: Form and Transformation : the Karṇāṭa Drāviḍa Tradition, 7th to 13th CenturiesBuddhist ArchitectureA History of India"The World Economy (GDP) : Historical Statistics by Professor Angus Maddison"The World Economy – Volume 1: A Millennial Perspective and Volume 2: Historical Statistics10.2307/32502140004-36483250214A Comprehensive History of India: Volume 2Between the Empires: Society in India, 300 to 400Emergence of Viṣṇu and Śiva Images in India: Numismatic and Sculptural Evidence"Parthian Pair of Earrings"the originalThe Medical Times and Gazette, Volume 1Greatest emporium in the worldThe Cambridge History of Ancient China: From the Origins of Civilization to 221 BCBuddhist Records of the Western WorldArchaeology in Soviet Central AsiaThe Grandeur of Gandhara: The Ancient Buddhist Civilization of the Swat, Peshawar, Kabul and Indus ValleysIndian Sculpture: Circa 500 B.C.-A.D. 700"The History of Pakistan: The Kushans"Gupta Dynasty – MSN Encartathe original"India – Historical Setting – The Classical Age – Gupta and Harsha""Gupta Dynasty, Golden Age Of India"the original"The Age of the Guptas and After"the originalNumber Theory and Its History"Gupta dynasty (Indian dynasty)""Gupta dynasty: empire in 4th century"the original"The Story of India – Photo Gallery"The ASI say499315420"Pallava script"p. 145"CNG: eAuction 329. INDIA, Post-Gupta (Ganges Valley). Vardhanas of Thanesar and Kanauj. Harshavardhana. Circa AD 606–647. AR Drachm (13mm, 2.28 g, 1h)""Harsha""Sthanvishvara (historical region, India)""Harsha (Indian emperor)"Shyama Kumar Chattopadhyaya (2000) The Philosophy of Sankar's Advaita VedantaShankara's IntroductionShankara's Introduction19373677Shankara's IntroductionIs The Buddhist 'No-Self' Doctrine Compatible With Pursuing Nirvana?The Seven Spiritual Laws Of YogaIndia: The Ancient Past. A History of the Indian-Subcontinent from 7000 BC to AD 1200The Kashmir Series: Glimpses of Kashmiri Culture – Vivekananda Kendra, Kanyakumari (p. 57).Al-Hind: Early Medieval India and the Expansion of Islam, 7th–11th CenturiesHistory of GopāchalaLand of Two Rivers: A History of Bengal from the Mahabharata to MujibEuropean Trade and Colonial ConquestA History of IndiaA Comprehensive History Of Ancient India (3 Vol. Set)"The Last Years of Cholas: The decline and fall of a dynasty"the originalFascinating Hindutva: Saffron Politics and Dalit MobilisationGazetteer of the province of OudhAl- Hind: The slave kings and the Islamic conquest. 2"Shahi Family"The Cambridge history of Islam"Ameer Nasir-ood-deen Subooktugeen"Gazetteer of the Attock District, 1930, Part 1Land of seven rivers: History of India's GeographyTemple Desecration and Indo-Muslim StatesIslam in South Asia: A Short HistoryBeyond Orientalism: The Work of Wilhelm Halbfass and Its Impact on Indian and Cross-cultural StudiesThe Making of Terrorism in Pakistan: Historical and Social Roots of ExtremismOrnament in Indian ArchitectureA historical review of Hindu India: 300 B.C. to 1200 A.D."Indian States and Union Territories"Islam in South Asia: A Short HistoryA Brief History of the Indian PeoplesThe Modern ReviewDelhi Sultanate"Battuta's Travels: Delhi, capital of Muslim India"the original"Timur – conquest of India"the originalIndia HandbookBhaktiThe Four Denomination of Hinduism10.1007/s11407-008-9049-925691067"Vijayanagara Research Project::Elephant Stables"10.2307/26465262646526Historical Dictionary of the TamilsBihar General Knowledge DigestMapping Bihar: From Medieval to Modern TimesPopular Literature and Pre-modern Societies in South AsiaA manual of the Kistna district in the presidency of MadrasAncient Indian History and CivilizationFragmented Memories: Struggling to be Tai-Ahom in India"The Islamic World to 1600: Rise of the Great Islamic Empires (The Mughal Empire)"the originalDynasties: A Global History of Power, 1300–1800, p. 105"Whose fort is it anyway"10.1111/0020-8833.000532600793Development Centre Studies The World Economy Historical Statistics: Historical Statistics"India's Deindustrialization in the 18th and 19th Centuries"The Mughal Empire, p. 190"The Long Globalization and Textile Producers in India"The Mughal World: Life in India's Last Golden AgeAurangzeb: The Life and Legacy of India's Most Controversial KingIn the Shadow of the Taj: A Portrait of Agra"Iran in the Age of the Raj"p. 8610.2307/20539802053980Delhi, the Capital of IndiaAn Advanced History of Modern India"Journal of the Tanjore Maharaja Serfoji's Sarasvati Mahal Library"The Rediscovery of India: A New SubcontinentIslamic Renaissance In South Asia (1707–1867) : The Role Of Shah Waliallah & His SuccessorsAn Advanced History of Modern IndiaThe Great Maratha Mahadaji Scindia"Full text of "Selections from the papers of Lord Metcalfe; late governor-general of India, governor of Jamaica, and governor-general of Canada""The Discovery Of IndiaThe Sacred City of the Hindus: An Account of Benares in Ancient and Modern TimesResurrecting Banaras: Urban Space, Architecture and Religious BoundariesFaith & Philosophy of Sikhism"Missiles mainstay of Pak's N-arsenal"History Modern India By S.N. Sen"Sirajuddaula"ArchivedLongman History & Civics (Dual Government in Bengal)Madhya Pradesh National Means-Cum-Merit Scholarship Exam (Warren Hasting's system of Dual Government)A Military History of Britain: from 1775 to the PresentIndian Cultural Heritage Perspective For TourismHindu Rulers, Muslim Subjects: Islam, Rights, and the History of KashmirIndian HistoryAn Atlas and Survey of South Asian HistoryAn Historical Account of the British Trade Over the Caspian SeaIndian Merchants and Eurasian Trade, 1600–1750The Indian diaspora in Central Asia and its trade, 1550–1900From Constantinople to the home of Omar Khayyam: travels in Transcaucasia and northern Persia for historic and literary researchA journey from Bengal to England: through the northern part of India, Kashmire, Afghanistan, and Persia, and into Russia, by the Caspian-SeaA Second Journey through Persia, Armenia, and Asia Minor, to Constantinople, between the Years 1810 and 1816Reports from the consuls of the United States, 1887Portugal and its Empire, 1250–1800 (Collected Essays in Memory of Glenn J. Ames).: Portuguese Studies Review, Vol. 17, No. 1The Dutch Power in Kerala, 1729–1758http://mod.nic.inArchivedDossier Goa – A Recusa do Sacrifício InútilAn Imperial Crisis in British India: The Manipur Uprising of 1891The Truth of Babri Mosque"Kolkata (Calcutta) : History"the original"Robert Clive, Baron Clive, 'Clive of India', 1725–1774""The Transformation from a Pre-Colonial to a Colonial Order: The Case of India"10.2307/25955872595587A versatile geniusArchived10.1109/MWSYM.1997.602854"Rabindranath Tagore on Education"the original"Essay on 'Derozio and the Young Bengal Movement'"Poverty and Famines: An Essay on Entitlement and Deprivation"Plague"the originalPopulation Growth and Land Use"Reintegrating India with the World Economy""Census Of India 1931"A history of modern India, 1480–1950"'India's well-timed diversification of army helped democracy' | Business Standard News"Bal Gangadhar Tilak: Struggle for Swaraj"Participants from the Indian subcontinent in the First World War""Commonwealth War Graves Commission Annual Report 2007–2008 Online"the original1462689197110.1017/s0010417500016534178920Eurocentrism: a marxian critical realist critique"Ranjit Guha, "On Some Aspects of Historiography of Colonial India""10.2307/2168385216838510.7202/016593ar"Harvard scholar says the idea of India dates to a much earlier time than the British or the Mughals""In The Footsteps of Pilgrims""India's spiritual landscape: The heavens and the earth""India: A Sacred Geography by Diana L Eck – review"Modern India: The Origins of an Asian Democracy10.2307/21694222169422964322464"The Indian Subcontinent and 'Out of Africa 1'"254043308Encyclopedia of World ReligionsThe Evolution and History of Human Populations in South Asia: Inter-disciplinary Studies in Archaeology, Biological Anthropology, Linguistics and Genetics"The Early Paleolithic of the Indian Subcontinent: Hominin Colonization, Dispersals and Occupation History"Ancient Indian History and CivilizationAncient Indian Social History: Some Interpretationsthe originalIndia Before EuropeA Concise History of Modern India"The beginning of the historical period, c. 500–150 BCE"full textA History of Indiathe originalexcerpt and text searchexcerptexcerptAn Economic History of India: From Pre-Colonial Times to 1991excerpt and text searchexcerpt and text searchIndia as known to the ancient world10.1111/j.1468-0289.1985.tb00391.x2597191onlineThe History of India, as told by its own historians. The Muhammadan Periodonline editionHans William Brown research collection on 19th-century missionary work in India, 1882–1932, Ms. Coll. 1033, Kislak Center for Special Collections, Rare Books and Manuscripts, University of Pennsylvaniaee